// JavaScript Document
//version1.08.dev.js
!function(KuoqiJs) {
    if ("object" == typeof exports && "undefined" != typeof module)
        module.exports = KuoqiJs();
    else if ("function" == typeof define && define.amd)
        define([], KuoqiJs);
    else {
        var t;
        t = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this,
        t.$Q = t.kuoqiJs = KuoqiJs();
    }
}(function() {
	var KuoqiJs;
	return function KuoqiJs(c){
		function a(){}
		if(c&&c.type=='KuoqiJsObject'){
			//这种情况为使用$Q的方法的情况,初始化的时候会执行这个
			KuoqiJs.__proto__ = c;
			
			//扩展插件的部分
			KuoqiJs.plugIn = {
				//注册插件的内容信息
				register:function(plugname,plugbody){
					KuoqiJs.library.plugIn.push(plugname);
					this[plugname] = plugbody;
				},
				//关于时间的插件,时间自动跑的那种
				time:function(opts){
					//todo--时间插件的相关信息
					return;
					opts.timestame = parseInt(opts.timestame);
					setInterval(function(){
						var date = new $Q.date({
							timeStamp:opts.timestame
						});
						k._e_e.selector(opts.boxElement).html(date.output());
						opts.timestame++;
					},1000);
				},
			},
			a = KuoqiJs;
		}else{
			//这种情况为使用$Q引入方法的情况	,后续使用过程中会执行这个
			a = KuoqiJs.selector(c);
			
		}
		return a;
	}({
		
		//-------------选择器 start-------------//
		
		//选择器
		selector:function(a,b,c){
			//如果已经是元素的话，就不做任何处理直接返回就好
			if(a&&a.Type=='Knodelist'){ return a;};
			var node = new function Knodelist(){
				//判定是否为字数开头，如果数字开头则使用span包裹
				var self = this;
				this.Type = 'Knodelist';//类型
				this.Function = null;//功能信息
				this.Selector = a;//选择器
				this.PseudoSelector = '';//伪类选择器
				this.PseudoSelectorIndex = 0;//伪类选择器里面的数字选项
				this.Limit = b?b:null;//父级选择器
				this.JustChild = c?c:0;//是否只有
				this.length = 0;//元素的个数
				//这是个选择器的具体类型
				//[object HTMLDocument] - document
				//[object Selector] - 常规带选择器的选择器
				//
				this.sType = null;//这是个选择器的具体类型
				
				this.Element = [];//元素列表信息
				this.Readylist = [];//ready的绑定的列表方法们
				this._callback = null;//单执行返回函数信息
				
				//初始化完成
				this.ready = function(func){
					if( Object.prototype.toString.call(func) == '[object Function]'){
						self.Function.library.readlist.push(func);
					}else{
						if(this.sType =='[object HTMLDocument]'){
							self.Function.library.readlist.forEach(function(e){
								self._callback = e;
								e();
							})
						}
					}
				};
				
				//增加一个class
				this.addClass = function(className){
					this.each(function(i,e){
						if(!self.Function.selector(this).hasClass(className)){
							if(this.classList==0){
								this.className = className;
							}else{
								(this.className += ' '+className)
							}
						}
					});
					return this;	
				};
				
				//after的相关信息
				this.after = function(s,debug){ return this.parent().next(s);};
				
				//异步同步内容信息
				this.ajaxConts = function(opts){
					var ths = this;
					opts = self.Function.opts(opts,{
						action:'',	
						data:{},
						method:'get',
						header:{},
					},'action');
					var p = self.Function.proxy(opts);
					p.success = function(a,b,c){
						ths.html(a);
						opts.success&&opts.success();
					};
					p.error = function(){
						ths.html('<span>404</span>');
						opts.error&&opts.error();
					};
					p.send();
				};
				
				//异步上传表单信息
				this.ajaxSubmit = function(opts){
					try{
						if(this.isValid()){
							var data =this.getFormdata(this);
							var action = this.getAttr('action');
							var method = this.getAttr('method');
							opts = self.Function.opts(opts,{
								action:action?action:"",	
								method:method?method:'get',
								data:{},
							});
							var proxy = self.Function.proxy(opts);
							proxy.setDatas(data);
							proxy.setDatas(opts.data);
							proxy.send();
						}else{
							self.Function.msg('Invalid form submission');
						};
						
					}catch(err){console.log(err);};
				};
				
				this.animation = function(opts){
					var self = this;
					opts = self.Function.opts(opts,{
						'focusElement':this,
						'rotateZangle':0,//旋转的时候Z转角
						'rotateZspeed':1,//旋转速度，【>0为顺时针，<0为逆时针】
						'rotateXangle':0,//旋转时候的X转角
						'rotateXspeed':0,//X轴旋转速度，【>0为顺时针，<0为逆时针】
						'rotateYangle':0,//旋转时候的Y转角
						'rotateYspeed':0,//Y轴旋转速度，【>0为顺时针，<0为逆时针】
						'timer':10,//ms
					},'animationType');
					return new function Kanimation(){
						this.opts = opts;
						opts.ths = this;
						this.doCircle = function(){
							//转圈圈的配置
							opts.focusElement.attr('data-animation-rotateZangle',opts.rotateZangle);
							var doThis = function(){
								var angle = opts.focusElement.attr('data-animation-rotateZangle');
								angle = parseFloat(angle);
								angle+=parseFloat(opts.rotateZspeed?opts.rotateZspeed:1);
								opts.focusElement.css('transform','rotate('+angle+'deg)');
								opts.focusElement.attr('data-animation-rotateZangle',angle);
								setTimeout(function(){
									doThis();
									},opts.timer);
							};
							doThis();
						};
						this.doRoute = function(code){
							//转圈圈的配置
							opts.focusElement.attr('data-animation-rotateZangle',opts.rotateZangle);
							var doThis = function(){
								var angle = opts.focusElement.attr('data-animation-rotateZangle');
								angle = parseFloat(angle);
								angle+=parseFloat(opts.rotateZspeed?opts.rotateZspeed:1);
								opts.focusElement.css('transform','rotate'+code+'('+angle+'deg)');
								opts.focusElement.attr('data-animation-rotateZangle',angle);
								setTimeout(function(){
									doThis();
									},opts.timer);
							};
							doThis();
						};
						this.doAnimation = function(){
							switch(opts.animationType){
								case 'circle':this.doCircle();break;
								case 'routeX':this.doRoute('X');break;
								case 'routeY':this.doRoute('Y');break;
								case 'routeZ':this.doRoute('Z');break;
							}
						};
						this.sync = function(){
							this.doAnimation();
						};
						this.sync();
					}
				};
				//待处理，增加元素信息
				this.append = function(s){
					if(s&&(s.Type=='Knodelist')){
						this.each(function(){
							var ths = this;
							self.Function.selector(s).each(function(){
								ths.appendChild(this);
							})
						});
						return this;
					}else if(Object.prototype.toString.call(s).indexOf('[object HTML')==0){
						this.each(function(){
							this.appendChild(s);
						});
						return this;
					}else if(Object.prototype.toString.call(s).indexOf('[object NodeList')==0){
						self.Function.selector(this).each(function(){
							var ths = this;
							self.Function.selector(s).each(function(){
								ths.appendChild(this);
							})	
						});
						return self.Function.selector(this);
						
					}else{
						var h = self.Function.parseHTML(s,true);
						self.Function.selector(this).each(function(){
							var ths = this;
							self.Function.selector(h).each(function(){
								ths.appendChild(this);
							})	
						});
						return self.Function.selector(this);
					};
				};
				this.attr = function(attrName,attrValue){
					if(!attrName)return null;
					return (attrValue==undefined)?this.getAttr(attrName):this.setAttr(attrName,attrValue);	
				};
				
				//获取上级的一个元素信息
				this.before = function(s){ return this.parent().prev(s);};
				
				this.change = function(a){
					(a==undefined)
					?((function(e){
						e.each(function(){
							this.onchange&&this.onchange();	
						})
					})(this))
					:((function(e){
						e.each(function(ei){
							ei.onchange = a;
						})
					})(this));
				};
				//获取子元素的信息的列表
				this.children = function(selector,neq){
					var nodeord = self.Function.selector(selector,this);
					var node = self.Function.selector();
					this.Element.forEach(function(e){
						for(var i = 0;i<e.children.length;i++){
							if(neq){
								if(e.children[i]==neq){
									continue;
								}	
							}
							if(nodeord.length){
								nodeord.each(function(ee){
									if(e.children[i]==ee){
										node.push(e.children[i]);
									}	
								});
							}else if(selector){
								
							}else{
								node.push(e.children[i]);
							}
						}
					});
					return node;
				};
				//绑定点击事件
				//这个事件是可以多使用的
				this.click = function(a){
					var ret = true;
					(a==undefined)?((function(ele){
						ele.each(function(e){
							ret *= e.click(a);
						})
					})(this)):((function(ele){
						ele.each(function(e){
							(a===false)?((function(e1){
								e.onclick = function(ev){
									if(ev==null){return false;}
									if(ev.stopPropagation){
										ev.stopPropagation();
									}else if(window.ev) { 
										window.ev.cancelBubble = true;
									}
								}
							})(e)):e.addEventListener("click",function(evt){
									this.a = a;
									this.a(evt);
								});
						})
					})(this));
				};
				//深度复制
				this.clone = function(){
					var str = '';
					this.each(function(){
						str += this.outerHTML;
					});
					return this.Function.selector(str);
				};
				//css
				this.css = function(a,b){
					return (typeof(a)=='object')
						?((function(ths){
							ths.each(function(){
								for(var i in a){
									this.style.setProperty(i,(typeof(a[i])=='function')?((a[i])(this)):a[i]);	
								}
							});
							return ths;	
						})(this))
						:(b==undefined)
							?((function(e){
								return e.style.getPropertyValue(a);
								})(this.first(true)))
							:((function(ths){
								ths.each(function(){
									this.style.setProperty(a,(typeof(b)=='function')?((b)(this)):b);
								})
					})(this));	
				};
				this.data = function(n,v){
					if(v==undefined){
						return this.getData(n);		
					}else{
						return this.setData(n,v);
					}	
				};
				//执行on
				this.doOn = function(en){
					this.each(function(i,e){
						this['on'+en]&&this['on'+en]()
					})
				};
				
				//数据循环
				this.each = function(_cbk){
					for(var i=0;i<this.Element.length;i++){
						this.Element[i]._cbk = _cbk;
						this.Element[i]._cbk(this.Element[i],i);
					}
					return true;
				};
				
				//清空内容
				this.empty = function(){
					this.each(function(i,e){
						this.innerHTML  = '';	
					});
					return this;
				};
				
				//获取第几个元素欣喜
				this.eq = function(index){
					return this.Function.selector(this.Element[ parseInt(index) - 1]);
				};
				//获取文件信息列表
				this.files = function(index){
					var files = [];
					this.each(function(e){
						if(e.files){
							for(var i=0;i<e.files.length;i++){
								files.push(e.files[i]);	
							}	
						};	
					});
					if(index!=undefined){
						return files[index]?files[index]:null;	
					}
					return files;
				};
				
				//查找子元素的相关信息
				this.find = function(selector){
					return self.Function.selector(selector,this,true);
				};
				
				//第一个元素
				this.first = function(isEle){
					var e = this.Element[0]?this.Element[0]:null;
					return isEle?e:this.Function.selector(e);
				};
				
				//获取第一个孩子
				this.firstChild = function(isEle){
					var e = this.Element[0]?this.Element[0].firstElementChild:null;
					return isEle?e:this.Function.selector(e);
				//最后一个元素
				};
				
				this.focus = function(fc){
					return fc
						?((function(ths){
							return (typeof(fc)=='function')?((function(){
								ths.addEventListener("focus",fc,true);
								return self.Function.selector(ths);
							})()):self.Function.selector(ths);
						})(this.first(true)))
						:((function(ths){
							ths.focus();
							return self.Function.selector(ths);
						})(this.first(true)))
				};
				
				//显示全屏和取消全屏
				this.fullScreen = function(callback){
					var docElm = this.first(true);
					if(!docElm){ this.Function.error("请使用元素来全屏");return;}
					if (docElm.requestFullscreen) {
						docElm.requestFullscreen();
					}
					else if (docElm.msRequestFullscreen) {
						docElm.msRequestFullscreen();
					}
					else if (docElm.mozRequestFullScreen) {
						docElm.mozRequestFullScreen();
					}
					else if (docElm.webkitRequestFullScreen) {
						docElm.webkitRequestFullScreen();
					}
					document.onfullscreenchange = function(){
						callback&&callback();
					}
				};
				this.getAttr = function(attributeName){
					var e = this.first(true);
					return e?e.getAttribute(attributeName):null;
				};
				
				//获取data的值
				this.getData = function(dataName){
					var e = this.first(true);
					return e?e.getAttribute("data-"+dataName):null;
				};
				//获取表单的值的信息
				this.getFormdata = function(){
					var formdata = {};
					try{
						var setData = function(nm,vl){
							var type = Object.prototype.toString.call(formdata[nm]);
							if(type=='[object Array]')
							{
								formdata[nm].push(vl);	
							}else{
	
								formdata[nm] = vl;	
							}
						};
						var getType  = function(ele){
							var tp = self.Function.selector(ele).getAttr('type');
							tp = self.Function.strtolower(tp);
							if(!tp){tp = '';}
							return tp;
						};
						this.find("[name]").each(function(ele){
							var tp = getType(ele);
							var nm = self.Function.selector(ele).attr('name');
							var hnm = /^([0-9a-zA-Z\_\[\]]+)(\[\])$/g.exec(nm);
							if(hnm){
								nm = hnm[1];
								if(!formdata[nm])formdata[nm] = [];
							}
							switch(tp){
								case 'checkbox':
									if(self.Function.selector(ele).prop('checked')){
										var vl = self.Function.selector(ele).val();
										setData(nm,vl);
									}
								break;
								case 'radio':
									if(self.Function.selector(ele).prop('checked')){
										var vl = self.Function.selector(ele).val();
										setData(nm,vl);
									}
								break;
								case 'file':
									var multiple = self.Function.selector(ele).getAttr('multiple');
									if(multiple == 'multiple'){
											var vl = self.Function.selector(ele).files();	
										}else{
											var vl = self.Function.selector(ele).files(0);	
										}
									setData(nm,vl);
								break;
								default:
									var vl = self.Function.selector(ele).val();
									setData(nm,vl);
							}
						});
					}catch(err){ console.log(err);}
					return formdata;
				};
				
				//尝试获取属性的值
				this.getProp = function(a){
					return this.first(true)[a];
				};
				
				this.hasAttr = function(abn){
					var e = this.first(true);
					return e?e.hasAttribute(abn):null;
				};
				//判定class是否存在
				this.hasClass = function(className){
					var a = false;
					var e = this.first(true);
					if(!e){return false;}
					for(var i = 0;i<e.classList.length;i++){
						if(e.classList[i]==className){
							a = true;
						}
					}
					return a;
				};
				this.hasData = function(dataName){
					var e = this.first(true);
					return e?e.hasAttribute("data-"+dataName):null;
				};
				//判定属性是否存在
				this.hasProp = function(a){
					return this.first(true)[a]?true:false;
				};
				
				//高度
				this.height = function(p){
					if(this.length==0){return 0;}
					return (p==undefined)?
					((function(e){
						return e.offsetHeight})(this.first(true)))
					:((function(ths){
						ths.each(function(){
							this.style.height = parseFloat(p)+"px";	
						});
						})(this));
				};
				//隐藏元素节点
				this.hide = function(){ return this.css('display','none')};
				
				//html内容信息
				this.html = function(opts){
					if(this.length==0){return null;}
					return (opts==undefined)
						?((function(e){return e?e.innerHTML:'';})(this.first(true)))
						:((function(ths){
							ths.empty();
							ths.each(function(){
								if(opts.Type&&opts.Type=='Knodelist'){
									var sths = self.Function.selector(this);
									opts.each(function(){
										sths?sths.append(this):null;
									})
								}else{
									this?this.innerHTML=opts:null;
								}
							})
						})(this))
				};
				//获取当前元素在父级元素中的序号
				this.index = function(){
					var ele = this.first(true);
					if(ele===null){ return -1;}
					var par = this.parent(true);
					for(var i =0;i<par.children.length;i++){
						if(ele == par.children[i]){
							return i;	
						}	
					}
					return -1;
				}
				//验证form表单的数据信息
				this.isValid = function(){ return this.isValied();};
				//验证form表单的数据信息
				this.isValied = function(){
					var ths = this;
					var form = this.first(true);
					if(form.tagName!='FORM'){ return;}
					var getType  = function(ele){
						var tp = self.Function.selector(ele).getData('type');
						tp = self.Function.strtolower(tp);
						if(!tp){tp = '';}
						return tp;
					};
					var isValied = true;//基础判定为已通过
					this.find("[name]").each(function(ele){
						var val = self.Function.selector(this).val();
						switch(getType(ele)){
							case 'require':
								if(val.length<1){
									self.Function.selector(ele).focus();
									ths.setProp('focusElement',ele);
									isValied = false;
								}
							break;
							default:;
						}
					});
					return isValied;
				};
				
				//获取最后一个元素
				this.last = function(isEle){
					var e = this.Element[this.Element.length-1]?this.Element[this.Element.length-1]:null;
					return isEle?e:this.Function.selector(e);
				};
				
				//获取最后一个孩子
				this.lastChild = function(isEle){
					var e = this.Element[this.Element.length-1]?this.Element[this.Element.length-1].lastElementChild:null;
					return isEle?e:this.Function.selector(e);
				};
				
				//moveToNext
				this.moveToNext = function()
				{
					var next = this.next().next();
					if(next.first(true)){
						this.parent().first(true).insertBefore(this.first(true),next.first(true));
					}else{
						this.parent().append(this.first(true));	
					}
				};
				
				//元素向上移动一个单位
				this.moveToPrev = function()
				{
					var prev = this.prev();
					if(prev.first(true)){
						this.parent().first(true).insertBefore(this.first(true),prev.first(true));	
					}else{
						this.parent().prepend(this.first(true));		
					}
				};
				
				//向下移动一个单位
				this.next = function(s)
				{
					if(s==undefined){
						var e = this.first(true);
						return self.Function.selector(e?e.nextElementSibling:null);
					}else{
						if(s&&s.Type&&s.Type=='Knodelist'){
							var h = s.first(true);
						}else if(Object.prototype.toString.call(s).indexOf('[object HTML')==0){
							var h = s;
						}else{
							var h = this.Function.parseHTML(s);
							h = h[0];
						};
						return this.Function.selector(this.parent().first(true).insertBefore(h,this.next().first(true)));
					}
				};
				
				this.on = function(code,evt){
					this.each(function(i,e){
						(evt==undefined)?(self.Function.selector(this).doOn(code)):((function(ths){
							var c = 'on'+ code;
							ths[c] = evt;
							})(this));
					})
				};
			
				//父级元素
				this.parent = function(isEle){
					if(this.first(true).parentElement){
						return isEle?this.first(true).parentElement:this.Function.selector(this.first(true).parentElement);
					}else{
						return this.Function.selector();
					}
				};
				//父级元素们
				this.parents = function(selector){
					var l = self.Function.selector(selector);
					if(l.length==0){ return null;}//如果元素不存在，则返回null
					var p = this.parent();
					if(p.length==0){ return null;}
					var n = self.Function.selector();
					l.each(function(e){
						if(e==p.first(true)){
							n.push(e);
						}
					});
					if(n.length==0){
						return p.parents(selector);
					}
					return n;
				};
				//第一个元素增加
				this.prepend = function(s){
					if(s==undefined){
						return self.Function.selector(this.prev());
					}else{
						this.each(function(){
							//循环当前信息
							//判定当前元素是否为第一个元素
							if(s&&s.Type&&s.Type=='Knodelist'){
								var h = s.first(true);
							}else if(Object.prototype.toString.call(s).indexOf('[object HTML')==0){
								var h = s;
							}else{
								//string
								var h = self.Function.parseHTML(s);
								h = h[0];
							}
							
							//判断当前是否有元素信息，话说没有元素信息的话，这里应该进不来吧，判断是否you孩子元素
							//如果没有的话，同append
							if(this.childNodes.length){
								//这个是you孩子元素的	
								//拉去第一个孩子
								this.insertBefore(h,this.firstChild);
							}else{
								//这个没有孩子啊，没有孩子的话，直接增加一个孩子就可以了
								this.appendChild(h);
							}
						});
					}
					//返回当前对象信息
					return this;
				};
				
				//向上移动一个元素信息
				this.prev = function(s){
					if(s==undefined){
						var e = this.first(true);
						return this.Function.selector(e?e.previousElementSibling:null);
					}else{
						this.each(function(){
							if(s&&s.Type&&s.Type=='Knodelist'){
								var h = s.first(true);
							}else if(Object.prototype.toString.call(s).indexOf('[object HTML')==0){
								var h = s;
							}else{
								var h = self.Function.parseHTML(s);
								h = h[0];
							};
							this.parentNode.insertBefore(h,this);
						});
					};
					return this;
				};
				
				this.prop = function(ppn,ppv){
					if(!ppn)return null;
					return (ppv===undefined)?this.getProp(ppn):this.setProp(ppn,ppv);
				};
				
				//增加元素进入列表中
				this.push = function(node){
					this.Element.push(node);
					this.length = this.Element.length;
				};
				
				//执行删除节点
				this.remove = function(){
					if(this.Element.length>0){
						this.each(function(e){
							var p;
							(p = e.parentNode)&&(p.removeChild(e));
						})
					}
				};
				
				this.removeAttr = function(attrName){
					this.each(function(e){
						e.removeAttribute(attrName);
					})
					return this;	
				};
				this.removeClass = function(className){
					this.each(function(e){
						var c = '';
						if(e.classList&&e.classList.length>0){
							for(var j=0;j<e.classList.length;j++){
								var a = e.classList[j];
								if(a!=className){
									if(c){
										c+=' '+a;	
									}else{
										c+=a;
									}
								}
							}
							e.className = c;
						}
					})
					return this;
				};
				this.removeData = function(dataName){
					this.each(function(e){
						e.removeAttribute("data-"+dataName);
					})
					return this;	
				};
				this.removeProp = function(propName){
					this.each(function(e){
						delete(e[propName])
					})
					return this;	
				};
				
				this.scrollToBottom = function(){
					this.each(function(e){
						//需要优化有滑动效果
						//top = parseInt(top);
						//if(!top){
						   //top = 0;
						//}
						//document.getElementById(id).scrollIntoView({ behavior: 'smooth',top:top})
						e.scrollTop = e.scrollHeight;
					})
				};
				
				//选择器相关信息------------------------------------
				//选择器相关信息------------------------------------
				//常规字符串的解析器
				this.selectorByString = function(){
					var list = this.Function.parseHTML(this.Selector);
					list.forEach(function(e){
						self.push(e);
					});
				};
				
				//通过元素列表做选择器
				this.selectorByNodelist = function(){
					for(var i = 0; i< this.Selector.length; i++){
						this.push(this.Selector[i]);
					}
				};
				//通过元素做选择器
				this.setectorByNode = function(){
					this.push(this.Selector);
				};
				
				//常规的选择器的解析器
				this.selectorBySelector = function(){
					//判定是否有伪类选择器
					this.Selector.replace(/(\S+)\:(\S+)/,function(rs,rs1,rs2){
						self.Selector = rs1;
						self.PseudoSelector = self.Function.strtoupper(rs2);
						rs2.replace(/^(\w+)\((\d+)\)$/,function(rs21,rs22,rs23){
							self.PseudoSelector = self.Function.strtoupper(rs22);
							self.PseudoSelectorIndex = rs23;
						});
						return ;
					});
					//获取选择器的相关信息
					if(this.Limit){
						var lis = [];
						this.Limit.each(function(e){
							var list = e.querySelectorAll(self.Selector);
							list.forEach(function(ee){
								lis.push(ee);
							});
						});
					}else{
						var lis = document.querySelectorAll(this.Selector);	
					}
					if(self.PseudoSelector=='FIRST'){
						if(lis.length){ self.push(lis[0]);}
					}else if(self.PseudoSelector=='LAST'){
						if(lis.length){
							self.push(lis[lis.length - 1]);	
						}
					}else if(self.PseudoSelector=='FIRSTCHILD'){
						console.log('FIRSTCHILD');
					}else if(self.PseudoSelector=='LASTCHILD'){
						console.log('LASTCHILD');
					}else if(self.PseudoSelector=='EQ'){
						lis.forEach(function(e,i){
							if(i+1 == self.PseudoSelectorIndex){
								self.push(e);
							}
						});
					}else if(self.PseudoSelector=='NEQ'){
						lis.forEach(function(e,i){
							if(i+1 != self.PseudoSelectorIndex){
								self.push(e);
							}
						});
					}else{
						lis.forEach(function(e,i){
							self.push(e);
						});
					}
				};
				
				//document的选择器
				//oading / 正在加载
				//document 仍在加载。
				//interactive / 可交互
				//complete / 完成
				this.selectorByDocument = function(){
					this.element = document;
					document.onreadystatechange = function(e){
						if(this.readyState=='complete'){
							self.ready();
						}
					}
				};
				
				this.selectorByOther = function(){
					if(/^\[object\sHTML/.test(this.sType)){
						this.setectorByNode();
					}
					if(/^\[object\sSVG/.test(this.sType)){
						this.setectorByNode();
					}
				};
				
				//设置一个原数的属性信息
				this.setAttr = function(attrName,attrVal){
					this.each(function(e){
						e.setAttribute(attrName,attrVal);	
					})
					return this;
				};
				//设置一个data
				this.setData = function(dataName,dataValue){
					this.each(function(e){
						e.setAttribute("data-"+dataName,dataValue);	
					})
					return this;
				};
				
				//元素选择器，element,a常规选择器。b.父级返回元素，c是否只查找b的子元素
				this.setProp = function(a,b){
					this.each(function(e){ e[a] = b;});return this;
				};
				
				//展示元素节点信息，使用行级区块
				this.show = function(){ this.css('display','block');};
				this.siblings = function(selecter){
					return this.parent().children(selecter,this.first(true));
				};
				//针对表单的提交
				this.submit = function(func){
					return (typeof(func)=='function')?((
						function(ths){
							ths.each(function(){
								this.onsubmit = function(){
									this._cbk = func;
									this._cbk();
									return false;
								}
							});
						}
					)(this)):((function(ths){
						ths.each(function(){
							this.submit();
							})
						})(this));
				};
			
				//文本内容,没有输入的情况，获取第一个元素的内容值
				this.text = function(text){
					if(text==undefined){
						 return this.first(true)?this.first(true).textContent:null;
					}else{
						this.each(function(e,i){
							e.textContent = text;	
						})
					}
					return this;
				};
				/*//todo--接触事件
				this.touch = function(){
					var ths = this;
					var touch = new function Ktoucher(){
						this.touchStart = null;
						this.touchMove = null;
						this.touchEnd = null;
						this.onMovePoint = 64;//移动计算的距离长度
						this.onLongPoint = 1000;//长按的时间尺度
						//标记长按的开始时间节点，在过程中保持不动才算是长按，如果移动则视为移动
						this.isTouchMove = false;//是否为移动类型
						this.isTouchLong = false;//是否为长按
						this.tmpTouchLongtimer = 0;//长按的接触时间节点
						this.onMoveToLeft = null;//向左移动
						this.onMoveToRight = null;//向右移动
						this.onTouchFocus = null;//开始接触
						this.onTouchBlur = null;//停止接触触发
						this.onTouchLong = null;//长按返回方法
						this.doMoveLength = function(){
							var sx = this.touchStart.touches[0].screenX;
							var sy = this.touchStart.touches[0].screenY;
							var ex = this.touchEnd.changedTouches[0].screenX;
							var ey = this.touchEnd.changedTouches[0].screenY;
							if(sx - ex >this.onMovePoint){
								this.onMoveToLeft&&this.onMoveToLeft(this);	
							}
							if(ex-sx>this.onMovePoint){
								this.onMoveToRight&&this.onMoveToRight(this);	
							}
						}
						//触发长按判定
						this.doLongPress = function(){
							if(!this.isTouchMove){
								//触发长按标识
								this.onTouchLong&&this.onTouchLong();	
							}
						};
						var that = this;
						self(ths).on('touchStart',function(rs){
							that.touchStart = rs;
							that.touchMove = null;
							that.touchEnd = null;
							that.isTouchMove = false;
							that.isTouchLong = false;
							that.tmpTouchLongtimer = setTimeout(function(){
									//如果这个期间没有发生移动，则触发长按
									that.doLongPress();
								},that.onLongPoint);
						});
						self.selector(ths).on('touchMove',function(rs){
							that.touchMove = rs;
							that.isTouchMove = true;
						});
						self.selector(ths).on('touchEnd',function(rs){
							that.touchEnd = rs;
							//执行长按的倒计时的释放
							if(that.tmpTouchLongtimer){
								clearTimeout(that.tmpTouchLongtimer);
								}
								
							that.doMoveLength();
						});
					};
					return touch;	
				};*/
				
				//val
				this.val = function(v){ 
					return (v==undefined)?((
						function(ths){
							
							return ths.value;
						}
					)(this.first(true))):((
						function(ths){
							ths.each(function(){
								this.value = v;	
								this.oninput&&this.oninput();
							})
							return ths;	
						}
					)(this))
				};
				
				//获取当前元素的宽度
				this.width = function(p){
					return (p==undefined)?
					((function(e){
						return e.offsetWidth})(this.first(true)))
					:((function(e){
						e.each(function(){
							this.style.width = parseFloat(p)+"px";	
						})
					})(this));
				};
				
				//解析元素的信息作为querySelect可识别的那种
				this.analysisSelector = function(){
					this.sType = Object.prototype.toString.call(a);
					if(this.sType == '[object String]'){
						if(!/\</.test(this.Selector)){
							this.sType = '[object Selector]';
						}
					}
					//console.log(this.sType);
					switch(this.sType){
						case '[object Selector]':this.selectorBySelector();break;//常规的选择器的解析器
						case '[object String]':this.selectorByString();break;//选择器为字符串的类型
						case '[object HTMLDocument]':this.selectorByDocument();break;//选择器为document的类型
						case '[object NodeList]':this.selectorByNodelist();break;//选择器为nodelist的类型
						case '[object HTMLCollection]':this.selectorByNodelist();break;//选择器为nodelist的类型
						//case /^\[object\sHTML/.test(this.sType):console.log(22);this.setectorByElement();break;//关于元素的类型
						default:this.selectorByOther();
						//console.error(this.sType+"暂无选择器类型")
					}
					this.length = this.Element.length;
				};
			};
			node.Function = this;
			node.analysisSelector();
			//node.ready();
			return node;
		},
		
		//-------------选择器 end-------------//
		
		//-------------选择器 function-------------//
		//ajax
		ajax:function(opts){
			var self = this;
			return new function kajax(){
				this.opts = self.opts(opts,{
					url:'',
					type:'get',
					data:{},
					dataType:'',
					success:function(){},
					error:function(){},
					isSec:false,//是否为分段请求
					//多请求判定函数
					secCheck:function(rs,yes_back,err_back){},
				});
				this.opts.method = this.opts.type;
				this.opts.action = this.opts.url;
				this.proxy = self.proxy(this.opts);
				this.proxy.send();
			}
		},
		
		//alert的弹窗
		alert:function(opts){
			var self = this;
			return new function kuoqialert(){
				var ths = this;
				this.opts = self.opts(opts,{
					tips:'',
					width:((function(){
						if(self.isMobile()){
							return '80%';
						}else{
							return '400px';
							}
						})()),
					text:'',
					class:'card card-api card-alert',
					sureText:'关闭',//确定按钮的内容
					sureStyle:'margin: 5px;vertical-align: bottom;box-sizing: border-box;background-color: unset;border: 1px solid #dedede;border-radius: 5px;padding: 5px 10px;opacity: 0.95;cursor: pointer;',
					cancel:function(){ return true;},
				},'text');
				this.opts.content = '<div style="margin:15px;">'+(this.opts.text?this.opts.text:"")+'</div>';
				this.card = self.card(this.opts);
				this.card.card.surebtn = self.selector('<button type="button" style="'+this.opts.sureStyle+'">'+this.opts.sureText+'</button>');
				this.card.card.surebtn.on('click',function(){
					ths.card.card.titleCloseBtn.click();
				});
				this.card.card.body.html(this.opts.content);
				this.card.card.foot.css("text-align","center");
				this.card.card.foot.html(this.card.card.surebtn);
			}
		},
		
		//base64编码
		base64encode:function(stream){ return window.btoa(stream);},
		
		//base64解码
		base64decode:function(stream){ return window.atob(stream);	},
		
		//一个卡片
		card:function(opts){
			var self = this;
			var card = function kuoqicard(opts){
				this.opts = opts;
				this.library = {
					format:{},
					content:'',
					position:'c',//c:[c,t,r,b,l,tr,tl,br,bl];
					title:'',//卡片的标题
					formatOptions : {
						head:{
							format:'head',
							classname:'card-head',
							css:{
								"display":"flex",
								"align-items":"center",
								"background-color":"#ddd",
								"padding":"0.25em 0.5em",
							},
							isshow:true,	
						},
						body:{
							format:'body',
							classname:'card-body',
							css:{
								"padding":"0.25em 0.5em",
							},
							isshow:true,
						},
						foot:{
							format:'foot',
							classname:'card-foot',
							css:{
								"padding":"0.25em 0.5em",	
							},
							isshow:true,	
						},
						card:{
							format:'card',
							classname:'',
							css:{
								"border":"1px solid #dedede",	
								"background-color":"#fff",
								"position":"fixed",
								"opacity":"0"
							},
							isshow:true,
						},
					},
					dragOffsetpoint:[0,0],
					dragIsrun : 0,//是否正在移动
					//是否拥有背景图层
				};
				this.has_mask = this.opts.hasMask;
				this.width = 0;//卡片宽度
				this.height = 0;//卡片高度
				this.fwidth = 0;//总宽度
				this.fheight = 0;//总高度
				this.x = 0;//x的坐标信息
				this.y = 0;//y的坐标信息
				this.isFull = 0;//是否全屏的卡片
				this.card = {};
				this.onCancel = null;//关闭的监听
				this.onLoaded = null;//加载完成执行
				//执行关闭的事件
				this.doCancel = function(e){
					this.doDestroy();
					this.onCancel&&this.onCancel();
				};
				
				//执行页面加载完成
				this.doLoaded = function(e){
					//console.log('执行了加载完成');
					this.onLoaded&&this.onLoaded();
				};
				//执行摧毁卡片
				this.doDestroy = function(){
					if(this.has_mask){
						this.card.backdrop.remove();
					}else{
						this.card.card.remove();
					}
					
				};
				
				//更新事件绑定
				this.syncEvent = function(){
					//关闭按钮点击
					var ths = this;
					this.card.titleCloseBtn.on('click',function(e){
						ths.doCancel(e);
					});	
					//执行拖拽,拖拽开始
					this.card.title.on('dragstart',function(e){
						ths.library.dragOffsetpoint 
							= [
								e.offsetX,
								e.offsetY,
							];
						ths.card.card.css("box-shadow","0px 0px 6px 2px");
						ths.card.card.css("opacity","0.6");
					});
					this.card.title.on('drag',function(e){
						if(e.clientX<=0){ return}
						if(!ths.library.dragIsrun){ ths.library.dragIsrun = 1; return;}
						ths.card.card.css("left",(e.pageX - ths.library.dragOffsetpoint[0]) +"px");
						ths.card.card.css("top",(e.pageY - ths.library.dragOffsetpoint[1])+"px");
					});
					this.card.title.on('dragend',function(e){
						ths.card.card.css("box-shadow","unset");
						ths.card.card.css("opacity","1");
						ths.library.dragIsrun = 0;
					});
				};
				
				//创建卡片到body中
				this.create = function(){
					this.card['card'].addClass(this.opts.classname);
					this.syncEvent();
					this.doLoaded();
					this.card.card.css("opacity",1);
				};
				
				//创建卡片内容区域到页面中
				this.createContent = function(callback){
					this.card['body'].html(this.library.content,function(e){
						callback&&callback();
					});
				};
				
				//创建卡片的位置及方法信息
				this.createPosition = function(){
					this.width = Math.ceil(this.card.card.width());
					this.height = Math.ceil(this.card.card.height());
					this.fwidth = Math.ceil(window.innerWidth);
					this.fheight = Math.ceil(window.innerHeight);
					positionC = function(ths){
						ths.x = (ths.fwidth - ths.width) / 2;
						ths.y = (ths.fheight - ths.height) / 2;
					};
					positionT = function(ths){
						ths.x = (ths.fwidth - ths.width) / 2;
						ths.y = 0;
					};
					positionR = function(ths){
						ths.x = (ths.fwidth - ths.width);
						ths.y = (ths.fheight - ths.height) / 2;
					};
					positionB = function(ths){
						ths.x = (ths.fwidth - ths.width) / 2;
						ths.y = (ths.fheight - ths.height);
					};
					positionL = function(ths){
						ths.x = 0;
						ths.y = (ths.fheight - ths.height) / 2;
					};
					positionTR = function(ths){
						ths.x = (ths.fwidth - ths.width);
						ths.y = 0;
					};
					positionBR = function(ths){
						ths.x = (ths.fwidth - ths.width);
						ths.y = (ths.fheight - ths.height);
					};
					positionBL = function(ths){
						ths.x = 0;
						ths.y = (ths.fheight - ths.height);
					};
					positionTL = function(ths){
						ths.x = 0;
						ths.y = 0;
					};
					//[c,t,r,b,l,tr,tl,br,bl]
					switch(this.library.position){
						case 'C':positionC(this);break;
						case 'T':positionT(this);break;
						case 'R':positionR(this);break;
						case 'B':positionB(this);break;
						case 'L':positionL(this);break;
						case 'TR':positionTR(this);break;
						case 'BR':positionBR(this);break;
						case 'BL':positionBL(this);break;
						case 'TL':positionTL(this);break;
						default:console.error('position '+this.library.position + 'is can not do this');	
					};
					this.card.card.css('left',this.x + "px");
					this.card.card.css('top',this.y + "px");
				};
				
				//创建UI的方法
				this.createUI = function(){
					this.card['backdrop'] = $Q('<div style="z-index:'+this.opts.zIndex+'"></div>');
					this.card['card'] = $Q('<div></div>');
					this.card['head'] = $Q('<div></div>');
					this.card['body'] = $Q('<div></div>');	
					this.card['foot'] = $Q('<div></div>');
					this.card['title'] = $Q('<div draggable="true" style="flex:auto;cursor: all-scroll;">'+(this.library.title?this.library.title:'&nbsp;')+'</div>');
					this.card['titleCtl'] = $Q('<div stype="padding-left: 1rem;"></div>');
					this.card['titleCtlMaxbtn'] = $Q('<button type="button" style="border: none;background-color: unset;color: inherit;">&nbsp;</button>');
					this.card['titleCtlMinbtn'] = $Q('<button type="button" style="border: none;background-color: unset;color: inherit;">&nbsp;</button>');
					this.card['titleCloseBtn'] = $Q('<button type="button" style="border: none;background-color: unset;color: inherit;">×</divbutton');
					//创建卡片信息到body中
					
					//head的部分
					if(this.library.format.head.isshow){
						this.card.card.append(this.card.head);
						this.card.head.css(this.library.format.head.css);
						this.card.head.addClass(this.library.format.head.classname);
						this.card.head.css(this.library.format.head.css);
						this.card.titleCtl.append(this.card.titleCtlMinbtn);
						this.card.titleCtl.append(this.card.titleCtlMaxbtn);
						this.card.titleCtl.append(this.card.titleCloseBtn);
						//执行将title写入到卡片中的程序
						this.card.head.append(this.card.title);
						this.card.head.append(this.card.titleCtl);
					}
					//body的部分
					if(this.library.format.body.isshow){
						this.card.card.append(this.card.body);
						this.card.body.addClass(this.library.format.body.classname);
						this.card.body.css(this.library.format.body.css);
						
					}
					//foot的部分
					if(this.library.format.foot.isshow){
						this.card.card.append(this.card.foot);
						this.card.foot.addClass(this.library.format.foot.classname);
						this.card.foot.css(this.library.format.foot.css);
					}
					//card的部分
					if(this.library.formatOptions.card.isshow){
						this.card.card.addClass(this.library.formatOptions.card.classname);
						this.card.card.css(this.library.formatOptions.card.css);
						if(this.opts.width){
							if(typeof(this.opts.width)=='number'){
								this.opts.width = this.opts.width+"px";
							}
							this.card.card.css("width",this.opts.width);
						}
						if(this.opts.height){
							if(typeof(this.opts.height)=='number'){
								this.opts.height = this.opts.height+"px";
							}
							this.card.card.css("height",this.opts.height);
						}
					}
					this.card['backdrop'].css({
						"position":"fixed",
						"left":"0",
						"top":"0",
						"right":"0",
						"bottom":"0"
					});
					if(this.has_mask){
						this.card['backdrop'].append(this.card['card']);
						self.selector('body').append(this.card['backdrop']);	
					}else{
						self.selector('body').append(this.card['card']);
					}
				};
				
				//创建一个format的参数信息
				analysisOptsFormatOne = function(part,def){
					return self.opts(part,def,'format');
				};
				
				//解析format参数信息
				this.analysisOptsFormat = function(){
					//判定头部是否存在呢
					var lis = ['head','body','foot'];
					var fmt = this.opts.format;
					for(var i = 0;i<fmt.length;i++){
						var tmp = new analysisOptsFormatOne(fmt[i],this.library.formatOptions[fmt[i]]);
						this.library.format[tmp["format"]] = tmp;
					}
					if(!this.library.format.head){
						this.library.format.head 
							= new analysisOptsFormatOne({format:'head',isshow:false},this.library.formatOptions.head);
					}
					if(!this.library.format.body){
						this.library.format.body 
							= new analysisOptsFormatOne({format:'body',isshow:false},this.library.formatOptions.body);
					}
					if(!this.library.format.foot){
						this.library.format.foot 
							= new analysisOptsFormatOne({format:'foot',isshow:false},this.library.formatOptions.foot);
					}
				}
				
				//初始化content参数
				this.analysisOptsContent = function(){
					var content = this.opts.content;
					this.library.content = self.selector(self.parseHTML(content));
					this.library.position = self.strtoupper(this.opts.position);
				}
				
				//初始化输入参数信息
				this.syncInput = function(){
					this.opts.classname||(this.opts.classname = this.opts.class);
					this.analysisOptsFormat();//初始化format参数信息
					this.analysisOptsContent();//初始化content参数
					this.library.title 
						= this.opts.title?this.opts.title:this.opts.tips;
					this.onCancel = this.opts.cancel;
					this.onLoaded = this.opts.loaded;
					this.library.content = this.opts.content;
				}
				//解析opts的format参数信息到library中
				this.syncInput();
				//执行创建UI的方法
				this.createUI();
				//执行创建的内容信息
				this.createContent();
				this.createPosition();
				this.create();
			}
			return new card(this.opts(opts,{
				classname:'',//配置额外的class
				width:0,//宽度的大小
				height:0,//高度的大小
				format:[
					'head',
					'body',
					'foot'],//格式化
				title:'',//卡片标题信息
				cancel:null,//点击关闭按钮返回
				loaded:null,//加载完成
				sure:null,//点击确认返回
				content:'',//内容区域的额外信息返回
				position:'c',//卡片的位置信息//c:[c,t,r,b,l,tr,tl,br,bl];
				backgroundClick:null,//背景点击触发事件，屏蔽卡片内的其它元素的点击穿透
				zIndex:0,//卡片的层级结构信息
				hasBgcolor:false,//是否拥有背景颜色
				bgColor:null,//如果有背景颜色的情况下背景颜色为多少
				autoCreate:true,//是否自动生成卡片
				callback:null,//卡片创建成功的除法的返回方法
				tips:'',//卡片的标题信息
				class:'card card-api',//alias classname
				hasMask:true,//是否拥有背景图层
			}));
		},
		
		
		
		//读取和获取配置
		config:function(cname,cvalue){
			if(cname){
				return ((cvalue==undefined)||(cvalue==null))? this.library.config[cname]:(this.library.config[cname] = cvalue) ;
			}else{
				return '';	
			}
		},
		//confirm确认弹窗
		confirm:function(opts){
			var self = this;	
			return new function kuoqiconfirm(){
				var ths = this;
				this.opts = self.opts(opts,{
					tips:'',
					width:((function(){
						if(self.isMobile()){
							return '80%';
						}else{
							return '400px';
							}
						})()),
					text:'',
					class:'card card-api card-confirm',
					sureText:'确定',//确定按钮的内容
					sureStyle:'margin: 5px;vertical-align: bottom;box-sizing: border-box;background-color: unset;border: 1px solid #dedede;border-radius: 5px;padding: 5px 10px;opacity: 0.95;cursor: pointer;',//确定按钮的样式
					cancelText:'取消',//确定按钮的内容
					cancelStyle:'margin: 5px;vertical-align: bottom;box-sizing: border-box;background-color: unset;border: 1px solid #dedede;border-radius: 5px;padding: 5px 10px;opacity: 0.95;cursor: pointer;',//确定按钮的样式
					sure:null,
					cancel:null,
				});
				this.onSure = null;//执行监听成功执行方法
				this.doSure = function(){
					this.onSure&&this.onSure();
					this.opts.sure&&this.opts.sure();
					ths.card.doDestroy();
				}
				this.opts.content = '<div style="margin:15px;">'+(this.opts.text?this.opts.text:"")+'</div>';
				this.card = self.card(this.opts);
				this.card.card.surebtn = self.selector('<button type="button" style="'+this.opts.sureStyle+'">'+this.opts.sureText+'</button>');
				this.card.card.cancelbtn = self.selector('<button type="button" style="'+this.opts.cancelStyle+'">'+this.opts.cancelText+'</button>');
				this.card.card.surebtn.on('click',function(e){
					ths.doSure();
				});
				this.card.card.cancelbtn.on('click',function(e){
					ths.card.card.titleCloseBtn.click();
				});
				this.card.card.body.html(this.opts.content);
				this.card.card.foot.css("text-align","center");
				this.card.card.foot.append(this.card.card.surebtn);
				this.card.card.foot.append(this.card.card.cancelbtn);
			}
		},

		//创建简单元素
		createElement:function(tagName){ return document.createElement(tagName);},
		//创建唯一标识,isRand:是否随机数
		createID:function(scale,isRand){
			return scale + (isRand ? Math.ceil(Math.random() * 100000):'');
		},
		//日期基础
		date:function(options){
			return new function Kdate(){
				var opts = this.opts = self.optionsInput(options,{
					format:'YYYY-mm-dd HH:ii:ss',//输出格式	
					//时间部分
					timeStamp:(new Date()).getTime() / 1000,
					stream:'',//最后一次正确输出
				},'timeStamp');
				opts.ths = this;
				if(this.opts.timeStamp){
					this.opts.timeStamp = parseInt(this.opts.timeStamp);
					this.date = new Date(this.opts.timeStamp * 1000);	
				}else{
					this.date = new Date();		
				}
				//获取年
				this.getYear = function(){ return this.date.getFullYear();};
				//获取月
				this.getMonth = function(){ return this.date.getMonth()+1;};
				//获取日
				this.getDate = function(){ return this.date.getDate();};
				//获取周几
				this.getDay = function(){ return this.date.getDay();};
				//获取小时
				this.getHours = function(){ return this.date.getHours();};
				//获取分钟
				this.getMinutes = function(){ return this.date.getMinutes();};
				//获取秒
				this.getSeconds = function(){ return this.date.getSeconds();};
				//获取时间戳
				this.getTime = function(){ return this.date.getTime();};
				//获取本月的天数
				this.getMonthDatenum = function(){
					var date = new Date(this.getYear(),this.getMonth());
					date.setTime(date.getTime() - 86400 * 1000);
					return date.getDate();
				};
				//获取年
				this.setYear = function(Y){ this.date.setFullYear(Y);return this;};
				//获取月
				this.setMonth = function(m){ this.date.setMonth(parseInt(m)-1);return this;};
				//获取日
				this.setDate = function(d){ this.date.setDate(d);return this;};
				//获取小时
				this.setHours = function(H){ this.date.setHours(H);return this;};
				//获取分钟
				this.setMinutes = function(m){ this.date.setMinutes(m);return this;};
				//获取秒
				this.setSeconds = function(s){ this.date.setSeconds(s);return this;};
				//设置时间戳
				this.setTime = function(t){ 
					this.date.setTime(parseFloat(t) * 1000);
					return this;
				};
				//设置向后时间戳
				this.next = function(nt){ 
					this.date.setTime(this.date.getTime() + parseFloat(nt) * 1000);
					return this;
				};
				//设置向前时间戳
				this.prev = function(pv){ 
					this.date.setTime(this.date.getTime() - parseFloat(pv) * 1000);
					return this;
				};
				//格式化字符串
				this.format = function(format){ this.opts.format = format;return this;};
				//输出
				this.output = function(format){
					if(format){ this.opts.stream = format;}else{ this.opts.stream = this.opts.format;}
					this.opts.stream = this.opts.stream.replace(/Y{1,4}/g,function(rs){
						return opts.ths.getYear().toString().substring(4-rs.length,4);
					});
					this.opts.stream = this.opts.stream.replace(/m{1,2}/g,function(rs){
						return self.strspad(opts.ths.getMonth(),'0',2);
					});
					this.opts.stream = this.opts.stream.replace(/d{1,2}/g,function(rs){
						return self.strspad(opts.ths.getDate(),'0',2);
					});
					this.opts.stream = this.opts.stream.replace(/H{1,2}/g,function(rs){
						return self.strspad(opts.ths.getHours(),'0',2);
					});
					this.opts.stream = this.opts.stream.replace(/i{1,2}/g,function(rs){
						return self.strspad(opts.ths.getMinutes(),'0',2);
					});
					this.opts.stream = this.opts.stream.replace(/s{1,2}/g,function(rs){
						return self.strspad(opts.ths.getSeconds(),'0',2);
					});
					return this.opts.stream;
				};
				
			}	
		},
		//todo--测试信息
		debug:function(opts,tips){
			//这里会展示一个debug按钮，到右下角
			if(this.library.debug_cfg.box){
				var box = this.library.debug_cfg.box;	
				var win = this.library.debug_cfg.win;
			}else{
				var box = this.library.debug_cfg.box = this("<div style='position: fixed;z-index: 519101;right: 1rem;bottom: 1rem;border: 1px solid;background-color: rgba(0, 0, 0, 0.8);color: #fff;border-radius: 0.25rem;padding: 0.25rem 0.5rem;font-size: small;'>Debug</div>");
				var win = this.library.debug_cfg.win = this("<div style='position: fixed;z-index: 519101;right: 10%;bottom: 10%;border: 1px solid;top: 10%;left: 10%;background-color: rgba(255, 255, 255, 0.8);border-radius: 0.5rem;padding: 0.5rem;overflow: hidden;display: none;'><div data-debug-win style='position: absolute;left: 0.5rem;top: 0.5rem;right: 0.5rem;bottom: 0.5rem;    overflow: auto;'></div><div data-debug-close style='position: absolute;right: -1.5rem;top: -1.5rem;width: 3rem;height: 3rem;border: 1px solid #000;border-radius: 50%;line-height: 4rem;text-indent: 0.5rem;background-color: #d00;color: #fff;z-index: 1;'>x</div></div>");
				kuoqiJs('body').append(box);
				kuoqiJs('body').append(win);
				//点击关闭按钮关闭当前的内容显示区域
				win.find('[data-debug-close]').click(function(){
					win.hide();
				});
				box.click(function(){
					win.show();
				});
			}
			//进行一个元素的展示
			var str = '<section style="position: relative;font-size: 0.85rem;line-height: 1.4rem;">';
			var debugObject = function(object,index){
				str += '<details>';
				str += '<summary>[Object:'+index+']</summary>';
				str += '<div>';
				for(var i in object){
					doDebug(object[i],i);
				}
				str += '</div>';
				str += '</details>';
			};
			var debugArray = function(object,index){
				str += '<details>';
				str += '<summary>[Array:'+index+']</summary>';
				str += '<div>';
				for(var i in object){

					doDebug(object[i],i);
				}
				str += '</div>';
				str += '</details>';
			};
			var doDebug = function (opts,index){
				//todo--debug
				str += '<div style="margin-left: 15px;">';
				var type = Object.prototype.toString.call(opts,index);
				if(/^\[object\sTouch/.test(type)){
					debugObject(opts,index);
				}else{
					switch(type){
						case '[object Object]':debugObject(opts,index);break;
						case '[object Array]':debugArray(opts,index);break;
						case '[object Function]':
							str += index + ' : [Function][]';
							break;
						case '[object String]':
							str += index + ' : [String]"'+opts+'"';
							break;
						case '[object Number]':
							str += index + ' : [Number]'+opts;
							break;
						case '[object HTMLDocument]':
							str += index + ' : [HTMLDocument]'+opts;
							break;
						case '[object Boolean]':
							str += index + ' : [Boolean]'+(opts?'true':'false');
							break;
						case '[object Null]':
							str += index + ' : [Null]'+'null';
							break;
						case '[object Undefined]':
							str += index + ' : [Undefined]'+'Undefined';
							break;
						default:str += index + ' : '+type;
					}
				}
				
				str += '</div>';
				return str;
			};
			doDebug(opts,tips?tips:"main");
			str += '</section>';
			win.find('[data-debug-win]').prepend(str);
		},
		
		//error，异常信息展示
		error:function(msg){
			console.warn('$Q.error:'+msg);
		},
		
		//todo--文件模块
		file:function(file){
			var self = this;
			return new function Kfile(){
				this.onprogress = null,//当前文件上传进度提示
				this.onsuccess = null,//上传成功执行
				this.onerror = null,//上传失败执行
				this.oncompress = null,//文件片段压缩进度信息，当然是当前片段的部分
				
				this.secMaxsize = 524288;//最大的大小，如果操作需要切片
				this.secSize = 0;//是否切片，非0则视为切片,非切片的时候需要保证文件完整性
				this.seclist = [];//放置扩展切片的地方
				this.secMaxnum = 0;//最大切片数量
				this.secMaxlev = 0;//最大切片数量级
				this.uploadStatus = 0;//0:等待上传，1：上传成功，2：上传中
				this.pointer = 0;//这个是文件指针
				this.fileReader = new FileReader();
				this.tryMaxnum = 5;//自动重试次数
				this.file = file;
				this.uploadName = 'filename';
				this.isUpload = 0;//上传状态
				this.isSec = 0;//切片状态
				
				
				//
				this.onUploadProgress = null,
				//当前片段上传触发
				this.onSecProgress = null,
				
				this.err = null;//异常结果信息
				
				
				
				
				//检测切片是否完成或者是否结尾
				this.secCheck = function(rs){return true;}
				
				this.md5 = '';//这个为扩展md5方法，需要用于验证数据完整性
				this.def_updata = {};//默认需要上传的数据们
				//默认的一些变量都放这里面吧，不重复就行
				this.tmp = {};
				
				this.sendIndex = 0;
				this.uploadSepeed = null;//上传进度显示方法
				var ths = this;
				this.getTmpurl = function(){
					return window.URL.createObjectURL(this.file);	
				};
				//尝试根据创建元素信息来创建文件信息
				//创建成功返回，和创建失败返回
				this.createBynone = function(_scall,_ecall){
					self.error('点击尝试创建文件对象','file->createBynone');
					var ths = this;
					var ele =  self.selector('<input hidden="" type="file" />');
					self.selector('body').append(ele);
					ele.change(function(){
						self.error('点击尝试创建文件对象返回','file->createBynone');
						ths.file = self.selector(this).files(0);
						self.selector(ele).remove();
						ths._callback = _scall;
						ths._callback&&ths._callback();
					});
					ele.click();
				};
				
				//获取文件名
				this.getFilename = function(){
					return this.file.name;
				};
				
				//获取文件大小
				this.getFilesize = function(isByte){
					return isByte?this.file.size:self.filebyte2size(this.file.size);
				};
				
				//获取一个待上传的片段
				this.getSecfileWithnoupload = function(){
					for(var i=0;i<this.seclist.length;i++){
						if(this.seclist[i].uploadStatus==0){
							return this.seclist[i];
						}	
					}
					return null;
				}
				
				//根据当前信息创建一个切片
				this.doCreateSecBynow = function(callback){
					var ths = this;
					var data = {};
					data.secSize = this.secSize;//每个切片大小
					data.pointer = this.pointer;//当前文件指针开始位置
					//切到当前文件
					var blob = this.file.slice(ths.pointer,ths.secSize+ths.pointer,ths.file.type);
					data['blob'] = blob;
					//这里返回关于当前切片的一些基本信息，这是压缩的
					//获取到本切片信息的具体内容取出来，为了md5
					this.fileReader.onloadend = function(){
						//获取文件对象信息
						var file = {};
						var conts = btoa(this.result);
						file.binary = new File([conts],ths.file.name,{type:ths.file.type});
						file.md5 = self.md5(conts);
						file.sec_id = self.strspad(ths.pointer,0,ths.secMaxlev);
						file.uploadStatus = 0;//0:等待上传，1：上传成功，2：上传中
						file.tryUploadnum = ths.tryMaxnum;//失败尝试重新请求的最大值
						file.tryUploadnow = 0;//失败尝试请求的数量
						ths.seclist.push(file);//将切片加入到当前列表中
						data.file = file;
						ths.oncompress&&ths.oncompress(k.error(0,'ok',data));//片段压缩反馈
						ths.pointer += ths.secSize;//将当前指针向后移动一个片段长度
						callback&&callback();
						return;
					}
					this.fileReader.readAsBinaryString(blob);//将数据绑定到文件阅读器中，为了将数据取出来
				};
				
				//当前文件获取一个切片并返回，如果超过位置则返回null,成功返回
				this.doCreateSec = function(callback){
					var ths = this;
					//执行切片的具体步骤信息
					if(this.pointer>=this.secMaxnum){
						self.error('切片完成，需要执行监听方法的话，在这里绑定','file');
						callback&&callback();	
					}else{
						//没有执行完毕，继续执行
						this.doCreateSecBynow(function(){
							//这个切片添加成功，执行下一个切片	
							ths.doCreateSec(callback);
						});
					}
				}
				
				//执行切片文件部分
				this.doSec = function(callback){
					if(!this.file){
						self.error('文件信息不存在，切片自动退出');
						return callback&&callback();
					}
					if(this.secSize){
						//初始化切片所有信息
						//获取当前文件信息
						this.seclist = [];
						this.pointer = 0;//文件指针归到起始位置
						this.secMaxnum = 0;//最大切片数量
						this.secMaxlev = 0;//最大切片数量级
						
						//获取最大切片数量
						this.secMaxnum = Math.ceil(this.file.size / this.secSize);
						//获取最大切片量级
						this.secMaxlev = Object(this.secMaxnum).toString().length;
						//执行切片的具体操作
						this.doCreateSec(function(){
							self.error('切片完成，等待下一步处理','file');
							callback&&callback();
						});
					}else{
						self.error('不需要切片');
						return callback&&callback();	
					}
				};
				
				//文件模块上传文件部分文件一次性完成发送数据方法
				this.upload_sendfull = function(){
					var ths = this;
					self.error('upload_sendfull','file');
					this.proxy.emptyDatas();//清空当前文件
					this.proxy.setData('upload_type','file');//配置上传数据类型
					this.proxy.setData(this.uploadName,this.file);
					this.proxy.setDatas(this.def_updata);//写入默认数据列表信息
					//成功执行方法
					this.proxy.success = function(rs){
						ths.isUpload = 1;//文件上传成功
						ths.onsuccess&&ths.onsuccess(rs);
					}
					//失败执行方法
					this.proxy.error = function(rs){
						ths.isUpload = 2;//文件上传失败
						ths.onerror&&ths.onerror(rs);	
					}
					this.proxy.send();
				}
				
				//文件模块上传文件上传文件片段信息
				this.upload_sendsec = function(callback){
					var ths = this;
					//发送一个片段的实际操作方法
					var send = function (){
						var sec = ths.getSecfileWithnoupload();
						if(sec){
							//片段信息存在，直接做执行的部分	
							k.debug('upload_sendsec','sec');
							ths.proxy.emptyDatas();//清空当前文件
							ths.proxy.setData('upload_type','sec');//配置上传数据类型
							ths.proxy.setData(ths.uploadName,sec.binary);
							ths.proxy.setData('md5',sec.md5);//配置上传数据类型
							ths.proxy.setDatas(ths.def_updata);//写入默认数据列表信息
							ths.proxy.success = function(rs){
								sec.uploadStatus = 1;
								//执行成功继续执行下一个片段信息
								send();
							};
							ths.proxy.error = function(rs){
								if(sec.tryUploadnow>=sec.tryUploadnum){
									//上传次数已经超过限制啦，这个直接判定为上传失败
									sec.uploadStatus = 2;	
								}else{
									//自动重试
									sec.uploadStatus = 0;
									sec.tryUploadnow++;
								}
								send();
							};
							ths.proxy.send();
						}else{
							//片段信息，已经不存在了，就当做已经发送完成
							//片段发送完毕，也就是上传成功了，该如何操作呢
							//当然是发送成功啦
							
							callback&&callback();
						}
					};
					send();
					
				}
				//代理部分
				this.proxy = self.proxy({
					dataType:'json',
					method:'post',
					data:{},
					//进度条监听信息
					progress:function(cfg){
						ths.onprogress&&ths.onprogress(cfg);//onProgress
					},
				});
				
				//文件上传部分
				this.upload = function(url){
					var ths = this;
					this.proxy.setUrl(url);
					//根据之前的信息判定是否需要
					if(this.secSize){
						self.error('文件上传被执行，需要分片','file.upload()');
						//执行切片操作
						this.doSec(function(){
							ths.upload_sendsec(function(){
								//发送完成
								self.error('上传完成','file');
								ths.isUpload = 1;//文件上传成功
								ths.onsuccess&&ths.onsuccess(ths);
							});
						});
					}else{
						self.error('文件上传被执行，不需要分片','file.upload()');
						this.upload_sendfull();
					}
				}
			}	
		},
		//文件列表模块
		files:function(){
			var self = this;
			return new function Kfilelist(){
				//尝试根据创建元素信息来创建文件信息
				var ths = this;
				this.createBynone = function(callback){
					var ths = this;
					var ele =  self.selector('<input multiple="multiple" hidden="" type="file" />');
					self.selector('body').append(ele);
					ele.change(function(){
						for(var i=0;i<this.files.length;i++){
							ths.files.push(self.file(this.files.item(i)));	
						}
						self.selector(ele).remove();
						ths.callback = callback;
						ths.callback&&ths.callback();
					});
					ele.click();

				};
				this.files = [];
				this.push = function(file){
					 this.files.push(self.file(file));	
				};
				this.each = function(func){
					for(var i=0;i<this.files.length;i++){
						this.tmpFile = func;
						this.tmpFile(i,this.files[i]);	
					}	
				};
				this.item = function(index){
					return this.files[index]?this.files[index]:self.file();	
				};
			}	
		},
		
		//文件大小转字符串,根据字符串转文件大小
		//文件字节转文本大小
		filebyte2size:function(b){
			b = parseInt(b);
			var u = '';
			if(b/1024>1){
				b = b/1024;
				u = "k";
			}
			if(b/1024>1){
				b = b/1024;
				u = "m";
			}
			return parseFloat(b).toFixed(2).toString() + u;
		},
		//文件文本大小转字节大小
		//已解析k,m
		filesize2byte:function(t){
			t = this.strtolower(t);
			var b = 1;//倍率
			t = t.replace(/[km]/,function(r1){
				if(r1 == 'm'){
					b = 1048576;
				}else if(r1=='k'){
					b = 1024;	
				}
				return '';
			});
			return parseFloat(t) * b;
		},
		
		//todo--form表单模块
		form:function(options){
			var self = this;
			return new function Kuoqiform (){
				var ths = this;
				//基础的元素列表信息
				this.element = null;
				//临时form表单信息
				this.tmp_form = null;
				//临时method
				this.tmp_method = 'get';
				this.tmp_action = '';
				this.tmp_enctype = 'multipart/form-data';
				this.tmp_target = 'self';
				
				//form表单的基础信息
				this.formdata = new FormData();
				
				//增加一个参数信息
				this.append = function(n,v){
					this.formdata.append(n,v);
				};
				
				//设置请求参数
				this.setAction = function(action){
					this.tmp_action = action;	
				}
				//设置请求方式
				this.setMethod = function(method){
					this.tmp_method = method;	
				}
				//配置enctype
				this.setEnctype = function(enctype){
					this.tmp_enctype = enctype;
				}
				//配置详细新目标
				this.setTarget = function(target){
					this.tmp_target = target;	
				}
				//打开新的窗口
				this.isNew = function(){
					this.tmp_target = 'new';	
				}
				
				//设置form表单的请求头
				this.setHeaders = function(){}
				
				//提交表单
				//提交表单到某个指定的链接地址
				this.submit = function(){
					if(this.tmp_form){
						//已经有表单信息了,执行表单的提交
						self(this.tmp_form).submit();
					}else{
						//没有表单信息
						this.install();
						this.submit();	
					}
				}
				//清除已有的表单信息
				this.clear = function(){
					return this.tmp_form?this.tmp_form.remove():'';	
				}
				
				//卸载
				this.uninstall = function(){
					this.clear();	
				}
				
				//初始化当前表单，实例化
				//是不需要显示出来的
				this.install = function(isShow){
					this.clear();
					isShow = isShow?isShow:0;
					this.tmp_form = self('<form></form>');
					self('body').append(this.tmp_form);
					this.tmp_form.append('<label style="display: block;"><span>请求地址：'+this.tmp_action+'</span></label>');
					this.tmp_form.append('<label style="display: block;"><span>请求方式：'+this.tmp_method+'</span></label>');
					this.formdata.forEach(function(v,n){
						ths.tmp_form.append('<label style="display: block;"><span>'+n+'</span><input name="'+n+'" value="'+v+'" /></label>');
					})
					this.tmp_form.attr('action',this.tmp_action);
					this.tmp_form.attr('method',this.tmp_method);
					this.tmp_form.attr('enctype',this.tmp_enctype);
					this.tmp_form.attr('target',this.tmp_target)
					if(isShow){
						this.tmp_form.show();
					}else{
						this.tmp_form.hide();	
					}
				}
				
				//打印信息
				this.print = function(){
					return this.install(1);
				}
				
				//执行初始化内容
				this.init = function(options){
					//判定输入的类型
					if(Object.prototype.toString.call(options)=='[object HTMLFormElement]'){
						//form表单的具体内容
						this.element = options;
					}else if(Object.prototype.toString.call(options)=='[object String]'){
						this.element = self(options).first(true);
						
					}else{
						return self.error('function customized');	
					}
					this.setMethod(self(this.element).attr('method'));
						this.setAction(self(this.element).attr('action'));
						this.setEnctype(self(this.element).attr('enctype'));
						this.setTarget(self(this.element).attr('target'));
				};
				//执行初始化
				this.init(options);
			}
		},
		
		//get请求
		get:function(url,dataType,success,error){
			return this.ajax({
				url:url,
				dataType:dataType,
				type:'get',
				success:success,
				error:error
			});
		},
		
		getConfig:function(n){
			return this.library.config[n]?this.library.config[n]:'';
		},
		
		//判定是否全屏信息
		isFullscreen:function(){
			return !!(
				document.fillscreen ||
				document.modFulIScreen ||
				document.webkitIsFullScreen ||
				document.webkitFullScreen ||
				document.msFullScreen
			);
		},
		//是否IOS端
		isIos:function(){
			var ua = navigator.userAgent;
			return!!ua.match(/(i[^;]+;( U;)? CPU.+Mac OS X)/);	
		},
		//判断是否移动端
		isMobile:function(){
			if (navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|IEMobile)/i)) {
                return true
            } else {
                return false;
            }
		},
		//判定是否为微信
		isWeixin:function(){
			var ua = navigator.userAgent.toLowerCase();
            var isWXWork = ua.match(/wxwork/i) == 'wxwork';
            var isWeixin = !isWXWork && ua.match(/micromessenger/i) == 'micromessenger';
			return isWeixin;	
		},
		
		jsonDecode:function(s){return this.parseJSON(s);},
		jsonEncode:function(o){return this.stringifyJSON(o);},
		
		loading : function(isShow){
			var self = this;
			(isShow===false)?((function(ths){
				ths.loadingEnd();	
			})(this)):((function(ths){
				self.getConfig('LOADING_IMG')?ths.loadingStartwithimg({
						img:self.getConfig('LOADING_IMG'),
						rotate:self.getConfig('LOADING_IMG_PROTATE'),
						scale:self.getConfig('LOADING_SCALE'),
						timer:self.getConfig('LOADING_TIMER')
					}):ths.loadingStart();	
			})(this))
		},
		loadingStart:function(){
			var self = this;
			return new function Kloading(){
				var ths = this;
				this.opts = self.opts({},{
					format:['body'],
					autoCreate:false,
				});
				this.card = self.card(this.opts);
				this.card.box1 = self.selector('<div style="width: 120px;height: 120px;position: relative;border-radius: 50%;border: 5px solid #4eee71;box-sizing: content-box;overflow: hidden;"></div>');
				this.card.box2 = self.selector('<div style="width: 110px;height: 110px;border-radius: 50%;border: 5px solid #a0b;;box-sizing: border-box;position: absolute;border-left-color: #fff;overflow: hidden;left: 5px;top: 5px;border-right-color: #fff;"></div>');
				this.card.box3 = self.selector('<div style="width: 90px;height: 90px;position: relative;border-radius: 50%;border: 5px solid #3F51B5;box-sizing: border-box;border-left-color: #fff;border-right-color: #fff;overflow: hidden;position: absolute;left: 15px; top: 15px;"></div>');
				this.card.box4 = self.selector('<div style="width: 80px;height: 80px;position: relative;border-radius: 50%;border: 5px solid #4eee71;padding: 5px;box-sizing: border-box;overflow: hidden;position: absolute;left: 20px;top: 20px;border-top-color: #fff;border-bottom-color: #fff;"></div>');
				this.card.box5 = self.selector('<div style="width: 60px;height: 60px;border-radius: 50%;box-sizing: content-box;position: absolute;background-color: #fff;left: 25px;top: 25px;border: 5px solid #E91E63;line-height: 60px;font-size: 12px;text-align: center;"></div>');
				this.card.box1.append(this.card.box2);
				this.card.box1.append(this.card.box3);
				this.card.box1.append(this.card.box4);
				this.card.box1.append(this.card.box5);
				this.card.box4.animation({
					animationType:'circle',
					rotateZspeed:2,
				})
				this.card.box3.animation({
					animationType:'circle',
					rotateZspeed:-4,
				})
				this.card.box2.animation({
					animationType:'circle',
					rotateZspeed:6,	
				})
				this.card.box5.text('loading..');
				this.card.card.body.append(this.card.box1);
				var card = this.card.card;
				this.card.card.card.css({
					'border':'none',
					'box-shadow':'none',
					'background':'none',
					'left':function(){
						var code = (window.innerWidth - card.card.width()) / 2;
						return code+'px';
					},
                    'top':function(){
                        var code = (window.innerHeight - card.card.height()) / 2;
                        return code+'px';
                    },
				});
				this.card.create();
				self.library.loading = this;
			}
		},
		
		loadingEnd:function(){
			this.library.loading&&this.library.loading.card&&this.library.loading.card.doCancel();
			this.library.loading = null;
		},
		
		loadingStartwithimg:function(opts){
			return new function Kloading(){
				this.opts = k._f.optionsInput(opts,{
					format:['body'],
					zIndex:'6519101',
					class:'card-loading',
					autoCreate:false,
				});
				this.card = new k._f.card(this.opts);
				this.card.box1 = k._e_e.selector('<div style="width: 120px;height: 120px;position: relative;border-radius: 50%;box-sizing: content-box;overflow: hidden;"></div>');
				this.card.box2 = k._e_e.selector('<img style="width: 120px;height: 120px;" src="'+opts.img+'"/>');
				this.card.box1.append(this.card.box2);
				this.card.box2.animation({
					animationType:opts.scale,
					rotateZspeed:opts.rotate,	
					timer:opts.timer
				})
				this.card.format.body.append(this.card.box1);
				this.card.format.card.css({
					'border':'none',
					'box-shadow':'none',
					'background':'none',
				});
				this.card.create();
				k._loading = this;
			}

		},
		//设置进程信息
		setProcess:function(n,v){
			var process = this.process();
			process.set(n,v);
		},
		//加载页面的相关信息
		loadpage:function(opts){
			return this.pageOpen(opts);
		},
		
		//md5
		md5:function(a){
			function b(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c}
			function c(a,b){return a<<b|a>>>32-b}
			function d(a,d,e,f,g,h){return b(c(b(b(d,a),b(f,h)),g),e)}
			function e(a,b,c,e,f,g,h){return d(b&c|~b&e,a,b,f,g,h)}
			function f(a,b,c,e,f,g,h){return d(b&e|c&~e,a,b,f,g,h)}
			function g(a,b,c,e,f,g,h){return d(b^c^e,a,b,f,g,h)}
			function h(a,b,c,e,f,g,h){return d(c^(b|~e),a,b,f,g,h)}
			function i(a,c){a[c>>5]|=128<<c%32,a[(c+64>>>9<<4)+14]=c;var d,i,j,k,l,m=1732584193,n=-271733879,o=-1732584194,p=271733878;for(d=0;d<a.length;d+=16)i=m,j=n,k=o,l=p,m=e(m,n,o,p,a[d],7,-680876936),p=e(p,m,n,o,a[d+1],12,-389564586),o=e(o,p,m,n,a[d+2],17,606105819),n=e(n,o,p,m,a[d+3],22,-1044525330),m=e(m,n,o,p,a[d+4],7,-176418897),p=e(p,m,n,o,a[d+5],12,1200080426),o=e(o,p,m,n,a[d+6],17,-1473231341),n=e(n,o,p,m,a[d+7],22,-45705983),m=e(m,n,o,p,a[d+8],7,1770035416),p=e(p,m,n,o,a[d+9],12,-1958414417),o=e(o,p,m,n,a[d+10],17,-42063),n=e(n,o,p,m,a[d+11],22,-1990404162),m=e(m,n,o,p,a[d+12],7,1804603682),p=e(p,m,n,o,a[d+13],12,-40341101),o=e(o,p,m,n,a[d+14],17,-1502002290),n=e(n,o,p,m,a[d+15],22,1236535329),m=f(m,n,o,p,a[d+1],5,-165796510),p=f(p,m,n,o,a[d+6],9,-1069501632),o=f(o,p,m,n,a[d+11],14,643717713),n=f(n,o,p,m,a[d],20,-373897302),m=f(m,n,o,p,a[d+5],5,-701558691),p=f(p,m,n,o,a[d+10],9,38016083),o=f(o,p,m,n,a[d+15],14,-660478335),n=f(n,o,p,m,a[d+4],20,-405537848),m=f(m,n,o,p,a[d+9],5,568446438),p=f(p,m,n,o,a[d+14],9,-1019803690),o=f(o,p,m,n,a[d+3],14,-187363961),n=f(n,o,p,m,a[d+8],20,1163531501),m=f(m,n,o,p,a[d+13],5,-1444681467),p=f(p,m,n,o,a[d+2],9,-51403784),o=f(o,p,m,n,a[d+7],14,1735328473),n=f(n,o,p,m,a[d+12],20,-1926607734),m=g(m,n,o,p,a[d+5],4,-378558),p=g(p,m,n,o,a[d+8],11,-2022574463),o=g(o,p,m,n,a[d+11],16,1839030562),n=g(n,o,p,m,a[d+14],23,-35309556),m=g(m,n,o,p,a[d+1],4,-1530992060),p=g(p,m,n,o,a[d+4],11,1272893353),o=g(o,p,m,n,a[d+7],16,-155497632),n=g(n,o,p,m,a[d+10],23,-1094730640),m=g(m,n,o,p,a[d+13],4,681279174),p=g(p,m,n,o,a[d],11,-358537222),o=g(o,p,m,n,a[d+3],16,-722521979),n=g(n,o,p,m,a[d+6],23,76029189),m=g(m,n,o,p,a[d+9],4,-640364487),p=g(p,m,n,o,a[d+12],11,-421815835),o=g(o,p,m,n,a[d+15],16,530742520),n=g(n,o,p,m,a[d+2],23,-995338651),m=h(m,n,o,p,a[d],6,-198630844),p=h(p,m,n,o,a[d+7],10,1126891415),o=h(o,p,m,n,a[d+14],15,-1416354905),n=h(n,o,p,m,a[d+5],21,-57434055),m=h(m,n,o,p,a[d+12],6,1700485571),p=h(p,m,n,o,a[d+3],10,-1894986606),o=h(o,p,m,n,a[d+10],15,-1051523),n=h(n,o,p,m,a[d+1],21,-2054922799),m=h(m,n,o,p,a[d+8],6,1873313359),p=h(p,m,n,o,a[d+15],10,-30611744),o=h(o,p,m,n,a[d+6],15,-1560198380),n=h(n,o,p,m,a[d+13],21,1309151649),m=h(m,n,o,p,a[d+4],6,-145523070),p=h(p,m,n,o,a[d+11],10,-1120210379),o=h(o,p,m,n,a[d+2],15,718787259),n=h(n,o,p,m,a[d+9],21,-343485551),m=b(m,i),n=b(n,j),o=b(o,k),p=b(p,l);return[m,n,o,p]}
			function j(a){var b,c="";for(b=0;b<32*a.length;b+=8)c+=String.fromCharCode(a[b>>5]>>>b%32&255);return c}
			function k(a){var b,c=[];for(c[(a.length>>2)-1]=void 0,b=0;b<c.length;b+=1)c[b]=0;for(b=0;b<8*a.length;b+=8)c[b>>5]|=(255&a.charCodeAt(b/8))<<b%32;return c}
			function l(a){return j(i(k(a),8*a.length))}
			function m(a,b){var c,d,e=k(a),f=[],g=[];for(f[15]=g[15]=void 0,e.length>16&&(e=i(e,8*a.length)),c=0;16>c;c+=1)f[c]=909522486^e[c],g[c]=1549556828^e[c];return d=i(f.concat(k(b)),512+8*b.length),j(i(g.concat(d),640))}
			function n(a){var b,c,d="0123456789abcdef",e="";for(c=0;c<a.length;c+=1)b=a.charCodeAt(c),e+=d.charAt(b>>>4&15)+d.charAt(15&b);return e}
			function o(a){return unescape(encodeURIComponent(a))}
			function p(a){return l(o(a))}
			function q(a){return n(p(a))}
			return q(a);
		},
		
		//msg的内容信息
		msg:function(opts){
			var self = this;
			if(this.library.msgindex){ console.log(this.library.msgindex);this.library.msgindex.doCancel();}
			return this.library.msgindex = new function kuoqimsg(){
				var ths = this;
				this.opts = self.opts(opts,
					{
						timeOut:2500,
						position:'c',
						class:'card card-api card-msg',
						format:['body'],
						success:null,//cancel别名
						zIndex:99,
						cancel:null,//关闭的时候触发
						hasMask:true,//是否拥有背景图层
					},'text');
				this.doCancel = function(){
					this.card.doCancel();
					this.opts.cancel&&this.opts.cancel();
					this.opts.success&&this.opts.success();
					self.library.msgindex = null;
				}
				this.content = this.opts.content = self.selector('<div style="padding: 5px 15px;color: #fff;">'+(this.opts.text?this.opts.text:"")+'</div>');
				this.card = self.card(this.opts);
				this.card.card.body.css("background-color","#6b6b6b");
				setTimeout(function(){
					ths.doCancel();
				},this.opts.timeOut);
			};
		},
		
		//将代码字符串转换为直接显示的那种字符串
		html2text:function(s,c){
			return s.toString().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/'/g, "&#39;");
		},
		
		//专门的参数输入信息
		opts:function(opts,init,defcode){
			var obejct = {};
			obejct.version = this.version;
			for(var i in obejct){
				if(init[i]==undefined){
					init[i] = obejct[i];
				}
			}
			if(typeof(opts)=='object'){
				if(Object.prototype.toString.call(opts).indexOf('[object HTML')==0){
					var tmp = opts;	
					opts = {element:tmp};
				}
			}else{
				if(defcode==undefined){defCode='text'}
				var tmp = opts;	
				opts = {};
				if(tmp!=undefined){
					opts[defcode] = tmp;
				}
			}
			for(var i in opts){
				init[i]=opts[i];	
			}
			return init;
		},
		//专门的参数输入信息
		optionsInput:function(options,initObject,defCode){
			return this.opts(options,initObject,defCode);
		},
		//打开页面信息
		pageOpen:function(opts){
			var self = this;
			return new function kuoqipage(){
				var ths = this;
				this.opts = self.opts(opts,{
					zIndex:0,
					url:'',
					tips:'-',
					classname:'card card-api card-page',
					id: self.createID('page',true),
					width:window.innerWidth+"px",
					height:window.innerHeight+"px",
					data:{},
					format : ['head','body'],
					callback:function(){},//执行成功执行
					pageBack:function(){}//数据返回
				},'url');
				this.id = this.opts.id;
				var str = self.urlEncode(this.opts.data);
				this.opts.url = this.opts.url+ (str?('?'+str):'');
				this.iframe = self.selector('<iframe src="'+opts.url+'"></iframe>');
				this.iframe.first(true).onload = function(){
					self.selector(this.contentDocument).find('html').attr('data-iframeid',ths.opts.templateId);
				}
				this.opts.content = this.iframe;
				this.iframe.css({
					'position': 'relative',
					'width':'100%',
					'border':'none',
					'vertical-align':'bottom',
					'height':'100%'
				});
				this.card = self.card(this.opts);
				this.card.card.body.css("padding","unset");
				this.resetBody = function(){
					var h1 = this.card.card.head.height();
					var h2 = this.card.card.body.height();
					var h3 = this.card.card.foot.height();
					var w1 = this.card.card.head.width();
					var w2 = this.card.card.body.width();
					var w3 = this.card.card.foot.width();
					h0 = this.card.card.card.height();
					w0 = this.card.card.card.width();
					if(w1+w3==0){
						this.card.card.body.width(w0 - w1 - w3);
						this.card.card.body.height(h0 - h1 - h3);
					}	
				}
				this.resetBody();
				var process = self.process();
				process.setPage(this.id,this);
				this.onMessage = null;
				this.doCancel = function(){
					this.card.doCancel();
					process.removePage(this.processName);
				}
				//执行接收到的数据信息
				this.doMessage = function(msg){
					if(this.opts.message){
						this._callback = this.opts.message;
						this._callback(msg);	
					}
					this.onMessage&&this.onMessage(msg);
				}	
			}
		},
		
		//页面间通讯，不能跨tab
		pageMessage : function(id,message){
			var prc = this.process();
			var page = prc.getPage(id);
			page&&page.doMessage&&page.doMessage(message);
		},
		
		pageClose:function(id,data){
			var prc = this.process();
			var page = prc.getPage(id);
			if(page){
				prc.removePage(page.processName);
				page.doCancel();
				return true;
			}else{
				return false;
			}
		},
	
		//html
		parseHTML:function(a,justDom,plabel){
			plabel = plabel?plabel:'div';
			var e = document.createElement(plabel);
			e.innerHTML = a;
			return justDom?e.children:e.childNodes;
		},
		
		//json
		parseJSON:function(s){
			try{return JSON.parse(s+"")}catch(err){
				try{
					return eval(s);
				}catch(err){
					return null;	
				}
			}
		},
		
		//xml
		parseXML:function(xmlString){
			var xmlDoc;  
			if(typeof xmlString == "string") {  
				if(document.implementation.createDocument) {  
					var parser = new DOMParser();  
					xmlDoc = parser.parseFromString(xmlString, "text/xml");  
				}else if(window.ActiveXObject) {  
					xmlDoc = new ActiveXObject("Microsoft.XMLDOM");  
					xmlDoc.async = false; 
					xmlDoc.loadXML(xmlString);  
				}  
			}else {  
				xmlDoc = xmlString;  
			}  
			return xmlDoc;
		},
		post:function(url,data,success,error){
			return this.ajax({
				url:url,
				dataType:'json',
				type:'post',
				data:data,
				success:success,
				error:error
			});
		},
		//带输入框的内容信息
		prompt:function(opts){
			var self = this;	
			return new function kuoqiprompt(){
				var ths = this;
				this.opts = self.opts(opts,{
					tips:'',
					width:((function(){
						if(self.isMobile()){
							return '80%';
						}else{
							return '400px';
							}
						})()),
					text:'',
					value:'',//默认显示的值
					type:'input',//类型
					textRows:4,//展示的行数，type="textarea"时生效
					class:'card card-api card-confirm',
					sureText:'确定',//确定按钮的内容
					sureStyle:'margin: 5px;vertical-align: bottom;box-sizing: border-box;background-color: unset;border: 1px solid #dedede;border-radius: 5px;padding: 5px 10px;opacity: 0.95;cursor: pointer;',//确定按钮的样式
					cancelText:'取消',//确定按钮的内容
					cancelStyle:'margin: 5px;vertical-align: bottom;box-sizing: border-box;background-color: unset;border: 1px solid #dedede;border-radius: 5px;padding: 5px 10px;opacity: 0.95;cursor: pointer;',//确定按钮的样式
					contentStyle:'margin:1em;',
					inputStyle:'line-height: 1.44rem;margin-top:0.5em;width:100%;',
					sure:null,
					cancel:null,
					checkValied:null,//检测值是否通过
				});
				this.contentType = self.strtolower(this.opts.type);//获取当前的content的类型
				this.onSure = null;//执行监听成功执行方法
				this.onCheckValied = this.opts.checkValied;
				this.doSure = function(){
					var content = this.input.val();
					if(this.onCheckValied){
						if(!this.onCheckValied(content)){
							//检测不通过，这个用户自定义
							return;
						}
					}
					this.onSure&&this.onSure(content);
					this.opts.sure&&this.opts.sure(content);
					ths.card.doDestroy();
				}
				this.content = self.selector('<div style="'+this.opts.contentStyle+'"><div>'+(this.opts.text?this.opts.text:"")+'</div><div></div></div>');
				this.card = self.card(this.opts);
				if(this.contentType=='textarea'){
                    this.input = self.selector('<textarea rows="'+this.opts.textRows+'" style="'+this.opts.inputStyle+'"></textarea>');
				}else{
                    this.input = self.selector('<input style="'+this.opts.inputStyle+'" />');
				}
				this.card.card.surebtn = self.selector('<button type="button" style="'+this.opts.sureStyle+'">'+this.opts.sureText+'</button>');
				this.card.card.cancelbtn = self.selector('<button type="button" style="'+this.opts.cancelStyle+'">'+this.opts.cancelText+'</button>');
				this.card.card.surebtn.on('click',function(e){
					ths.doSure();
				});
				this.card.card.cancelbtn.on('click',function(e){
					ths.card.card.titleCloseBtn.click();
				});
				this.content.lastChild().html(this.input);
				this.card.card.body.html(this.content);
				this.card.card.foot.css("text-align","center");
				this.card.card.foot.append(this.card.card.surebtn);
				this.card.card.foot.append(this.card.card.cancelbtn);
			}
		},
		//接口代理模块
		proxy:function(opts){
			var self = this;
			opts = this.opts(opts,{
				action:'',//执行请求地址
				method:'get',//执行请求
				//返回数据类型
				//"",string,json,jsonp
				dataType:'',//
				data:{},
				//"",arraybuffer,blob,document,json,text,ms-stream
				responseType:'',
				success:function(){},//执行成功
				error:function(){},//执行失败
				progress:function(){},//当前执行进度
				header:{
					"X-Requested-With":"XMLHttpRequest"
				}
			});
			return new function Kproxy(){
				this.opts = opts;
				this.state = 0;
				this.dataType = self.strtoupper(this.opts.dataType);
				this.response = '';
				this.success = this.opts.success;
				this.error = this.opts.error;
				this._data = new FormData();
				this.upload = null;
				this.isSuccess = true;
				this.XMLHttpRequest = ((function(){
					return (window.XMLHttpRequest)
					?(new XMLHttpRequest()):((function(){
						try {
							return new ActiveXObject("Microsoft.XMLHTTP");
						}catch (e) {
							try {
								return new ActiveXObject("Microsoft.XMLHTTP");  
							}catch(er){console.log("创建代理对象错误")}
						}
					})());	
				})());
				this.emptyDatas=function(){ this._data = new FormData()},
				//配置上传的url部分
				this.setUrl = function(url){this.opts.action = url;}
				
				
				this.hasData = function(code){
					if(this._data.get(code)){return true}else{return false;}	
				}
				this.setData = function(n,v){
					if(Object.prototype.toString.call(v)=='[object Object]'||Object.prototype.toString.call(v)=='[object Array]'){
						this.setDataswithchild(v,n);
					}else{
						this._data.set(n,v);
					}	
				}
				this.setDataswithchild=function(datas,parCode){
					for(var i in datas){
						if(datas[i]&&(typeof(datas[i])=='object')){
							this.setDataswithchild(datas[i],parCode+"["+i+"]");	
						}else{
							this._data.append(parCode+"["+i+"]",datas[i]);	
						}
					}	
				},
				this.setDatas = function(datas){
					for(var i in datas){
						this.setData(i,datas[i]);	
					}
				}
				
				//处理返回数据信息
				this.responseDeal = function(xmlres){
					if((xmlres.status>=200)&&(xmlres.status<300)){
						this.isSuccess = true;	
					}else{
						this.isSuccess = false;
					}
					switch(this.dataType){
						case 'JSON':
							this.response = self.jsonDecode(xmlres.responseText);
							if(this.response==null){
								this.isSuccess = false;	
							}
						break;
						case 'BLOB':
							this.response = xmlres.response;
						break;
						default:this.response = xmlres.responseText;
					}
					if(this.isSuccess){
						this.success&&this.success(this.response);
					}else{
						this.error&&this.error();
					}
				}
				
				//上传组键的一些初始化
				this.uploadInit = function(){
					this.upload = this.XMLHttpRequest.upload;
					this.upload.startTime = null;
					this.upload.endTime = null;

					this.upload.speedmsg = 0;
					this.upload.speed = 0;
					this.upload.loadedSize = 0;
					this.upload.fileSize = 0;
					this.upload.perSize = '0%';
					this.upload.units = 'b/s';
					this.upload.onloadstart = function(q){
						this.endTime = this.startTime = new Date().getTime();
						this.fileSize = this.loadedSize = 0;
					};
					this.upload.onloadend = function(){}
					this.upload.onprogress = function(q){
						if(q.lengthComputable) {
							this.fileSize = q.total;//文件总大小
							this.perSize = Math.round(this.loadedSize / this.fileSize * 100) + "%";
							var nt = new Date().getTime(),
							pt = (nt-this.endTime)/1000;
							this.endTime = nt;
							var preload = q.loaded - this.loadedSize;
							this.speed = preload / pt;
							this.loadedSize = q.loaded;
							if(this.speed/1024>1){
								this.speed = this.speed/1024;
								this.units = "k/s";
							}
							if(this.speed/1024>1){
								this.speed = this.speed/1024;
								this.units = "M/s";
							}
							this.speed = this.speed.toFixed(2);
							this.speedmsg = this.speed+this.units;
							opts.progress&&opts.progress(this);
						}	
					}
				}
				
				//返回
				this.respose = null;
				
				//发送过程中推送数据流
				this.pushStream = function(){
					var ths = this;
					for(var i in ths.opts.header){
						this.XMLHttpRequest.setRequestHeader(i,ths.opts.header[i]);
					}
					this.XMLHttpRequest.responseType = this.opts.responseType;
					this.XMLHttpRequest.onreadystatechange = function(){
						ths.state = this.readyState;
						if(this.readyState==4){
							ths.responseDeal(this);
						}
					}	
					this.uploadInit();
				};
				
				//参数初始化【paramInit】
				this.paramInit = function(){
					var ths = this;
					this.opts.method = self.strtoupper(this.opts.method);
					switch(this.opts.method){
						case 'GET':
							//get的相关配置及操作
							//获取参数信息
							var getstr = '';
							this._data.forEach(function(v,n){
								if(getstr){
									getstr += '&'+n+'='+v;
								}else{
									getstr += n+'='+v;
								}
							});
							ths.noActionpram = true;
							this.opts.action = this.opts.action.replace(/(\?)(.*)$/,function(p1,p2,p3){
									ths.noActionpram = false;
									if(p3){
										return p2+p3+'&'+getstr;
									}else{
										if(getstr){
											return'?'+getstr;
										}else{
											return '';
										}
									}
								});
							if(ths.noActionpram&&getstr){
								this.opts.action += '?'+getstr;

							}
						;break;
						case 'POST':;break;
						default:;
					}
				}
				
				//发送数据信息
				this.send = function(){
					//配置参数信息
					this.setDatas(this.opts.data);
					this.paramInit();//参数初始化
					this.XMLHttpRequest.open(this.opts.method,this.opts.action,true);
					this.pushStream();
					this.XMLHttpRequest.send(this._data);
				}
			}
		},
		//退出全屏方法
		quitFullscreen:function(callback){
			if (document.exitFullscreen) {
				document.exitFullscreen();
			}
			else if (document.msExitFullscreen) {
				document.msExitFullscreen();
			}
			else if (document.mozCancelFullScreen) {
				document.mozCancelFullScreen();
			}
			else if (document.webkitCancelFullScreen) {
				document.webkitCancelFullScreen();
			}
			document.onfullscreenchange = function(){
				callback&&callback();
			}
		},
		
		//初始化信息
		ready:function(a){
			console.log('ready');	
		},
		
		//random的别名方法
		rand:function(){ return Math.random();},
		//随机数生成器
		random:function(){ return parseInt(Math.random() * 10000000 );},
		//随机rgb颜色
		randRgb:function(){
			return parseInt(Math.random()*16).toString(16)
				+parseInt(Math.random()*16).toString(16)
				+parseInt(Math.random()*16).toString(16);
		},
		
		setConfig:function(n,v){
			return this.library.config[n] = v;	
		},
		
		//socket的正式版本
		socket:function(config){
			var self = this;
			return new function KuoqiWebSocket (){
				this.config = self.optionsInput(config,{
					url:'ws:\/\/0.0.0.0:6519',//链接字符串
					//默认String,[支持string,json格式],如果使用json模式，返回非json的数据将被自动过滤掉，不会返回信息
					dataType:'',//返回的数据能使用的格式，
					data:{message:''},//额外的数据信息
					autoConnect:true,//是否为自动链接
					onOpen:null,//打开的时候触发本方法
					onError:null,//异常的监听
					onClose:null,//链接关闭的触发本方法
					onHeartbeat:null,//心跳检测触发本方法
					onHandle:null,//链接握手执行返回本方法
					onMessage:null,//收到信息触发本方法
					timeOut:5000,//默认超时时间
				},'url');
				//message-列表，params:每次发送信息传递的参数列表
				this.library = {message:[],ready:[],params:this.config.data};
				this.onOpen = this.config.onOpen;//执行打开成功的监听
				this.onError = this.config.onError;//异常的监听
				this.onClose = this.config.onClose;//关闭的监听
				this._callback = null;
				this.ready = function(ready){
					var ths = this;
					if(ready&&(typeof(ready)=='function')){
						this.library.ready.push(ready);
					}else{
						this.library.ready.forEach(function(func){
							ths._callback = func;
							ths._callback();
						});
					}
				}
				//获取当前状态信息
				this.stateMessage=function(){
					switch(this.socket.readyState){
						case 0:return "正在连接通讯";
						case 1:return "通讯连接成功";
						case 3:return "正在关闭通讯";
						default:return "通讯已关闭";	
					}
				},
				//绑定接收到信息
				this.onMessage = function(msg){
					var ths = this;
					this.library.message.forEach(function(func){
						ths._callback = func;
						ths._callback(msg);
					});
				};
				//接收消息的方法函数，这个是内部使用的
				this.message = function(rs){
					if(rs&&(typeof(rs)=='function')){
						this.library.message.push(rs);
					}
				}
				//关于接受到消息的模块的返回
				this.doMessage = function(rs){
					if(self.strtolower(this.config.dataType)=='json'){
						//json格式的数据
						this.onMessage(self.jsonDecode(rs.data));
					}else{
						//string根式的数据
						this.onMessage(rs.data);
					}
				},
				
				//这里是执行socket
				//创建的方法
				this.doConnect = function(){
					var ths = this;
					this.socket = new WebSocket(this.config.url);//打开服务端
					//open
					this.socket.onopen = function(evt){
						ths.onOpen&&ths.onOpen(evt);
						ths.ready();
					};
					//error
					this.socket.onerror = function(evt){
						ths.onError&&ths.onError(evt);
					};
					//close
					this.socket.onclose = function(evt){
						ths.onClose&&ths.onClose(evt);
					};
					//message
					this.socket.onmessage = function(evt){
						ths.doMessage&&ths.doMessage(evt);
					};
					setTimeout(function(){
						if(ths.socket.readyState==0){
							ths.socket.close();	
						}
					},this.config.timeOut);
				}
				
				//执行一个发送信息
				this.doSend = function(message){
					this.socket.send(message);
				}
				
				//执行一个send的完整信息
				this.send = function(cfg){
					if(!cfg){return null;}
					//参数信息
					if(typeof(cfg)!='object'){
						console.log('发送失败，请传入一个Hash进行发送数据请求');return;
					}
					var data = {};
					//装入参数基本信息
					for(var i in this.library.params){
						data[i] = this.library.params[i];	
					}
					//装入现在的用户信息
					for(var i in cfg){
						data[i] = cfg[i];
					}
					if(this.socket.readyState==1){
						var blob = new Blob(
							[self.jsonEncode(data)],
							{type: "application/octet-stream"}
						);
						this.doSend(blob);
					}else{
						console.warn(this.stateMessage());
					}	
				},
				//执行链接的方法
				//如果没有自动执行，请手动执行，使用this.doConnect();
				this.config.autoConnect&&this.doConnect();
			}
		},
		//停止事件后续处理
		stopEvent:function(){
			if(event.stopPropagation){
				event.stopPropagation();
			}else if(window.event) { 
				window.event.cancelBubble = true;
			}
		},
		
		stringifyJSON:function(o){return JSON.stringify(o)},
		strspad:function(s,c,l){ return s.toString().padStart(l,c);},//左侧填补指定数据到长度
		strepad:function(s,c,l){ return s.toString().padEnd(l,c);},//右侧填补指定数据到指定长度
		strtoupper:function(s){ return s?s.toUpperCase():null;},
		strtolower:function(s){ return s?s.toLowerCase():null;},
		strtoworder:function(s){ return s.slice(0,1).toUpperCase()+ s.slice(1)},
		//时间格式化
		timeformat:function(code){
			var s = parseInt(code);
			var m = parseInt (s / 60 );
			s = s % 60;
			var h = parseInt(m / 60);
			m = m % 60;
			return (h?h:0) + ":" + (m?this.strspad(m,'0',2):'00') + ":" + (s?this.strspad(s,'0',2):'00');
		},
		
		
		
		upload:function(opts){
			var ths = this;
			var opts = this.opts(opts,{
				url:this.getConfig('UPLOAD_URI'),//上传文件地址
				multiple:false,//是否多文件上传，[true:是，false:否]
				secSize:this.getConfig('UPLOAD_SEC_SIZE'),//使用切片的话，切片大小
				data:this.getConfig('UPLOAD_PARAMS'),//额外绑定数据信息
				uploadname:'filename',//绑定上传文件名
				success:null,//请求成功执行
				error:null,//请求失败执行
				progress:null,//进度变更执行		
				cancel:null,//用户关闭上传执行
				compress:null,//压缩时候执行
			});
			if(opts.multiple){
				var files = this.files();
				files.secSize = this.filesize2byte(Object(opts.secSize).toString());
				files.createBynone(function(){
					function getItemNeedupload(){
						for(var i = 0 ;i<files.files.length;i++){
							if(!files.files[i].isUpload){
								return files.files[i];
							}
						}
						return null;
					}
					function UploadOne(){
						var file = getItemNeedupload();
						if(file){
							//单个文件执行上传
							file.onsuccess = function(){
								//执行当前文件上传完成
								//继续执行下一个文件上传
								UploadOne();	
							};
							file.onerror = function(){
								//当前文件上传失败，继续执行下一个文件
								UploadOne();	
							};
							file.onprogress = function(){console.log('onprogress');};
							file.oncompress = function(){console.log('oncompress');};
							file.def_updata = opts.data;//默认上传数据放置
							file.uploadName = opts.uploadname;
							file.secSize = files.secSize;
							file.upload(opts.action);//文件上传
						}else{
							//执行返回的部分
							file.onsuccess = opts.success;
							file.onerror = opts.error;
							file.onprogress = opts.progress;
							file.oncompress = opts.compress;
						}
					}
					UploadOne();
				});
			}else{
				//单位件上传	
				var file = this.file();
				file.onsuccess = opts.success;
				file.onerror = opts.error;
				file.onprogress = opts.progress;
				file.oncompress = opts.compress;
				file.def_updata = opts.data;//默认上传数据放置
				file.uploadName = opts.uploadname;
				file.secSize = this.filesize2byte(Object(opts.secSize).toString());
				file.createBynone(function(){
					file.upload(opts.action);	
				});	
			}
		},
		
		//长度单位转换为数字
		unitlen2int : function(code){
			code = this.strtoupper(code);
			code.replace(/^([\d\.]+)(PX|VW|VH)$/,function(rs,num,unit){
				switch(unit){
					case 'PX':code = num;break;	
					case 'VW':code = window.innerWidth * num / 100;break;
					case 'VH':code = window.innerHeight * num / 100;break;
				}
			});
			return parseFloat(code);
		},
		//url decode
		urlDecode:function(code){
			var arr = [];
			var tml = code.split('&');
			for(var i = 0;i<tml.length;i++){
				var tmp = tml[i].split('=');
				arr[tmp[0]] = tmp[1]?tmp[1]:null;
			};
			return arr;
		},
		//url encode
		urlEncode:function(code){
			var str = '';
			for(var i in code){
				if(str){
					str += '&'+i+'='+code[i];	
				}else{
					str += i+ '=' + code[i];	
				}
			};
			return str;
		},
		//验签数据
		validata:function(type,data){
			type = this.strtolower(type);
			switch(type){
				//手机号码验签
				case 'tel':return /^1[\d]{10}$/.test(data);
				default:return true;	
			}
		},
		ID:'_'+Math.ceil(Math.random() * 100000),
		
		//参数数据库相关信息
		library:{
			DEBUG:true,//系统调试模式，开启后系统debug信息会启动
			plugIn:[],	
			config:{
				FORM_IMG_URL:'',//form表单中图片上传的链接信息
				FORM_IMG_DATA:{},//form表单中图片上传额外数据信息写入
				UPLOAD_URI:'',//文件上传的默认链接信息
				UPLOAD_SEC_SIZE:0,//上传文件切片大小限制，为0则不限制
				UPLOAD_PARAMS:{},//文件上传参数的相关额外数据
			},
			debug_cfg:{
				box:null,//debug里面配置的盒子元素	
			},
			msgindex:null,//msg弹窗的唯一标识
			loading:null,//绑定当前的loading的信息
			process:null,//进程管理模型
			readlist:[],//read列表信息
			/*LOADING_IMG:null,//是否使用图片的模式加载loading，如果不为空，则视为加载loading图片
			LOADING_IMG_PROTATE:0,//如果旋转每次旋转的角度，配置为0则不旋转	
			LOADING_TIMER:100,//定时器
			LOADING_SCALE:'circle',//loading加载场景
			CARD_HEAD_H:40,//卡片head的高度px
			CARD_FOOT_H:40,//卡片foot的高度px
			
			//关于图片自动上传模块的相关配置
			UPLOAD:{
				ACTION:'',//配置的默认上传地址，不配置则自动默认当前地址
				PARAMS:{},//默认调用的额外配置，默认为空，使用post的方式上传
				SEC_SIZE:'1M',//默认使用切片模式，如果配置这个大小则使用切片的方式上传
			},*/
		},
		
		//process-
		//注册并维护一个顶层的对象信息
		process:function(){
			if(this.isTop){
				//这个是顶部配置
				if(window.kuoqiJs.library.process){
					return window.kuoqiJs.library.process;	
				}else{
					return window.kuoqiJs.library.process = new function kuoqiJsProcess(){
						this.set = function(n,v){ this.library[n] = v;}
						this.get = function(n){ return this.library[n];}
						this.setPage = function(n,data){
							data.processName = n;
							data.processIndex = this.library.page.push(data) - 1;
						}
						this.getPage = function(n){
							//在索引中查找ID是否存在
							n = n?n:'';
							if(n){
								for(var i=0 ; i<this.library.page.length;i++){
									if(this.library.page[i].processName==n){
										return this.library.page[i];
									}
								}
								return null;
							}else{
								return this.library.page[(this.library.page.length - 1)];	
							}
						}
						this.removePage = function(n){
							var lis = [];
							for(var i = 0;i<this.library.page.length;i++){
								if(this.library.page[i].processName!=n){
									lis.push(this.library.page[i]);
								}
							}
							this.library.page = lis;
						}
						this.library = {
							page:[],
						};
					}	
				}
			}else{
				return window.top.kuoqiJs.process();
			}
		},
		//是否顶层
		isTop:((function(){
			if(window.top == window){
				return true;
			}else{
				return false;	
			}	
		})()),
		//属性唯一标识，标识这个脚本是kuoqi的核心脚本
		type:'KuoqiJsObject',
		version:'1.08',
	})
})